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'));
});
});
精彩评论