开发者

How to get a value of the property in jquery?

The code looks like this,

<a cla开发者_Python百科ss="foo" title="a"></a>
<a class="foo" title="b"></a>
<a class="foo" title="c"></a>

How can I get the second value of title when clicking the second ?


$('.foo').click(function(){
   alert($(this).attr('title'));
});

Try it!


Very easy:

$('a.foo').click(function() {
  console.log($(this).attr('title'));
});


Hope this will help you

 $(document).ready(function(){

        $(".foo").click(function(){
            alert($(this).attr("title"));

        });
    });


something like

$('.foo').click(function() {
    alert($(this).attr('title'));
});


$(".foo").click(function(){
    $(this).attr("title");
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜