Newbie question about attr()
I am trying to get the "id" of an object (or any attribute, really). I am building the objects from a database, so I set the id attribute equal to the unique id from the database. I am having the same problem getting any attribute, so I am using the alt attribute below (it's a bit simpler example).
This code:
-
alert($(this).html());
Returns:
-
<img style="border: 0px none ; margin-top: 5px; margin-left: 3px; margin-right: 3px;" src="images/RedDown.png" alt="Vote Down">
However, this code:
-
alert($(this).attr("alt"));
Returns:
undefined
Am I using the attr function incorrectly?