开发者

How to get a value of the property in jquery?

开发者 https://www.devze.com 2023-03-14 15:10 出处:网络
The code looks like this, <a cla开发者_Python百科ss=\"foo\" title=\"a\"></a> <a class=\"foo\" title=\"b\"></a>

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

精彩评论

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