jquery - Event bubbling up to match the original selector -


i have recurring problem event bubbling jquery i'm looking super simple solution to.

let's have link:

<a href="http://www.google.com" class="link"><span>link text</span></a> 

and bind click event jquery with:

$('.menu a.item').bind('click', function(e){     e.stoppropagation();     e.preventdefault();     var obj = $(e.target);     // obj }); 

the problem consistently face above , similar bindings if inner html of element has other tags events become target.

that's fine dandy of course, i'm wondering if there quick , easy way parent() until parent() obj equal selector "a.item" can grab href value , it.

in above case, simple $(e.target).parent().attr('href') work in case there 3 or 4 levels deep of child elements.

does have ideas?

just use this instead of e.target

http://jsfiddle.net/fax4j/


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -