I'm new to jquery and am facing now a weird problem. I succeeded to narrow it down to the fact that a mouseenter event is called twice: once for the containing div (this was my intention) and again for elements within this div (not good). I tried to use 'return false' and 'stopPropagation' but it doesn't seem to work. here's the code:
<!-- JS files (order matters!) -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.js"></script>
<script type="text/javascript">
$(function (){
$(".testDiv").hover(
function(e) /* IN */ {
$(this).data("htmlBackup", $(this).html());
$(this).html("TEST 123");
e.stopPropagation();
return false;
}, function(e) /* OUT */ {
$(this).html($(this).data("htmlBackup"));
e.stopPropagation();
return false;
});
});
</script>
<!-- this one works -->
<div class="testDiv" style="border: solid">ORIG HTML</div>
<br /> <br /> <br />
<!-- this doesn't work -->
<div class="testDiv" style="border: solid"> <p style="border: solid">ORIG HTML</p></div>
you can also see it here: http://jsfiddle.net/rFqyP/3/
Any help will be very much appreciated!