开发者

jQuery - Get title attribute using each

I have this jquery code:

$.each('.button.gobutton', function() {
      alert($(this).attr('title'));
 });

I basically want to iterate 开发者_如何学Cthrough each element and get the value of the title for each element. However when I run this code I get undefined for all the values. Below is the html:

<button class="button gobutton" title="2">GO</button>


$.each iterates over arrays/objects. It doesn't select DOM elements.

It seems like you're trying to do this:

$('.button.gobutton').each(function() {
      alert($(this).attr('title'));
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜