I need to add the one attribute of all of a certain element to an array:
Here is the html:
<a class="umb" name="/wordpress/images/custom-slideshow/image1.jpg">
<a class="umb" name="/wordpress/images/custom-slideshow/image2.jpg">
<a class="umb" name="/wordpress/images/custom-slideshow/image3.jpg">
Here is the jQuery
var theImages = new Array();
$('.umb').each(function(){
theImages.push($(this).attr('name'));
});
alert(theImages.length);
t开发者_StackOverflow中文版his alerts different numbers in different browsers
in Firefox "15" in IE8 "3" in Chrome "6" in Opera "3" in Safari "12"The right answer is of course "3". Can't figure out why this is happening.
Well on a quick test of this I get 3 in Safari 5, but it could be because different browsers will attempt to correct the unclosed anchor tags in different ways (assuming that wasn't a paste error). Each anchor should should have a </a> at the end.
精彩评论