C
christopher.secord
I'm having a hard time understanding an error that I'm getting. In the
code below, I'm trying to call substring() on an attribute of an
anchor. The error I get says "getAttribute("rel") has no properties"
The reason this confuses me is that getAttribute("rel") returns a
string, so it should have all the properties and methods of a string,
right?? What am I missing here?
- chris
var AnchorArray = document.getElementsByTagName("a");
for (var i = 0; i < AnchorArray.length; i++) {
if (AnchorArray.getAttribute("rel").substring(0,5) == "other")
alert("hi there");
}
code below, I'm trying to call substring() on an attribute of an
anchor. The error I get says "getAttribute("rel") has no properties"
The reason this confuses me is that getAttribute("rel") returns a
string, so it should have all the properties and methods of a string,
right?? What am I missing here?
- chris
var AnchorArray = document.getElementsByTagName("a");
for (var i = 0; i < AnchorArray.length; i++) {
if (AnchorArray.getAttribute("rel").substring(0,5) == "other")
alert("hi there");
}