jquery click & get value of attributes of a href

http://stackoverflow.com/questions/6625667/jquery-click-get-value-of-attributes-of-a-href

 

/* Add a listner to Group buttons */
    $(‘a.preActNav‘).click(function() { 
        alert(this.seq)
    });   



    <li><a href="#preclose4" data-theme="a" data-icon="arrow-d" data-transition="none" seq=‘1‘ class="preActNav"  ID="preActNavA">A</a></li>
    <li><a href="#preclose4" data-theme="a" data-icon="arrow-d" data-transition="none" seq=‘2‘ class="preActNav"  ID="preActNavB">B</a></li>


alert($(this).attr(‘seq‘));

Although it may be better to put seq as another data element:

<li><a href="#preclose4" data-theme="a" data-icon="arrow-d" data-transition="none" data-seq=‘1‘ class="preActNav"  ID="preActNavA">A</a></li>

So then you can do:

alert($(this).data(‘seq‘));

jquery click & get value of attributes of a href,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。