How to define a link using custom attributes using jQuery?
2 answers
Use the attribute selector:
$("a[track]").click(function(e){ // Your code }); Example: http://jsfiddle.net/jonathon/uXwSF/
As andre points out in the comments, if you want to get only links where track='yes' , then do:
$("a[track='yes']").click(function(e){ // Your code }); If you want to get all the links with the track attribute, but know what that value is:
$("a[track]").click(function(e){ var shouldTrack = $(this).attr('track'); }); +7