Suppose I have this jQuery code.
$(document).delegate('a[title]', 'click', function(event) {
var txt = // href value of the link ;
alert("txt");
})
How do I obtain the value of the href attribute of the link? I cannot use $(this) because that would refer to $(document).
better use
.on()from jQuery (1.7+) since.delegate(),.bind()and.live()will be deprecated.DEMO
ideally, you would want to bind the handler to the nearest common parent of all the elements you want affected. binding it to
documentis a long distance call from element, which can incur serious performance penalties..live()and advises to use.on().delegate().on()over.bind()for flexible handling: