JavaScript DOM HTML attribute property: isId
[this page | pdf | back links]
The isId property
of HTML attribute
objects within the JavaScript
DOM returns true if the attribute is an ID
attribute, otherwise returns false.
Most browsers no longer seem to support this property.
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
<a href="http://www.nematrian.com" id="element">link to www.nematrian.com</a>
<br>(has href = http://www.nematrian.com and id = element)
<br><br><em>Attribute details for this hyperlink:</em><br>
number of attributes: <b><span id="attr1"></span></b><br>
name and value of first attribute<br>
<b> <span id="attr2"></span></b><br>
whether first attribute is an id (note: most broswers no longer seem to support the isId property)<br>
<b><span id="attr3"></span></b><br>
name and value of second attribute and whether it has been specified:<br>
<b><span id="attr4"></span></b>
<script>
var x = document.getElementById("element");
document.getElementById("attr1").innerHTML = x.attributes.length;
var y1 = x.attributes[0];
document.getElementById("attr2").innerHTML = y1.name + ", " + y1.value;
document.getElementById("attr3").innerHTML = y1.isId;
var y2 = x.attributes[1];
document.getElementById("attr4").innerHTML = y2.name + ", " + y2.value + ", " + y2.specified;
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)