jquery - Removed .live() $(document).bind('click',selector) problems -


im using

$(document).bind('click','.q',function(e){console.dir(e.target);}); 

my html so:

<div class="b"style="width:1000px;height:1000px">     <div class="q"style="width:10px;height:10px"></div>     <div class="q"style="width:10px;height:10px"></div>     more .q added later...  </div> 

but when click anywhere on .b (before .q appended) console giving me dir e.target of .b

why?

i using code because live() removed.

so code have been

$('.q').live('click',function(e){console.dir(e.target);}); 

bind doesn't support delegate events second parameter eventdata.
should use on instead of bind:

// not document better performance. $('div.b').on('click','.q', function(e){console.dir(e.target);}); 

you can reach eventdata parameter with: e.data, if console see ".q" in console.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -