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

Does IE 6 Support HTML5 Custom Data Attributes?

Barbara Streisand
Barbara StreisandOriginal
2024-11-16 11:05:03136browse

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>

Can the following JavaScript retrieve the attribute's value:

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

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'));

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!

Statement:
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