jQuery won't assign proper this value for handler

nhvippii7

New Member
I've been trying to assign handlers to divs with class "item-image", but the this variable will always point to the first div of class "item-image". This example is simplified. I originally attempted delegation, but it also had the same result.Here is my jquery:\[code\] $('div.item-image').on('click', function(){ alert($(this).html()); });\[/code\]Here is my html:\[code\]<table><tr><td><div class="item-image"> <div class="item-image-url" style="display: none;"> </div> test <div> </div> test <div> </div></div></td><td><div class="item-image"> <div class="item-image-url" style="display: none;"> </div> test2 <div> </div> test2 <div> </div></div></td><td><div class="item-image"> <div class="item-image-url" style="display: none;"> </div> test3 <div> </div> test3 <div> </div></div></td></tr></table>\[/code\]Thanks in advance!
 
Back
Top