开发者

Select links with certain attribute

i am trying to sele开发者_StackOverflowct all links with a certain attribute, for some reason it dosent work, can anyone help ?

HTML

<a href="javascript:;" title="Edit">Edit</a>

JQUERY

$('a[title="Edit"]').click(function (e) {
    e.preventDefault;
    alert($(this).attr('title'));
})


Your attribute selector looks correct. I suspect you are failing to attach that click handler when the DOM is ready for JavaScript processing:

$(document).ready(function() {
    $('a[title="Edit"]').click(function (e) {
        e.preventDefault;
        alert($(this).attr('title'));
    });
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜