Home > Web Front-end > JS Tutorial > Does IE 6 Support HTML5 Custom Data Attributes?

Does IE 6 Support HTML5 Custom Data Attributes?

Barbara Streisand
Release: 2024-11-16 11:05:03
Original
220 people have browsed it

Does IE 6 Support HTML5 Custom Data Attributes?

Can IE 6 Handle HTML5 Custom Data Attributes?

The question arises whether custom data attributes introduced in HTML5 are functional in IE 6. Specifically, if an HTML element contains a custom attribute:

<div>
Copy after login

Can the following JavaScript retrieve the attribute's value:

var geoff = document.getElementById('geoff');
alert(geoff.dataGeoff);
Copy after login

Answer:

Contrary to the assumption, this technique works in IE 6. However, it's essential to use getAttribute instead of accessing the custom attribute directly via dataGeoff. The correct method is:

var geoff = document.getElementById('geoff');
alert(geoff.getAttribute('data-geoff'));
Copy after login

This approach is not specific to HTML5 but works with any custom attribute in IE6.

The above is the detailed content of Does IE 6 Support HTML5 Custom Data Attributes?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template