.live() not working properly when using multiple events
In jQuery 1.4 Hawtness #1, with Paul Irish, there is a code snippet that binds multiple events to a selector using the .live() method.
Here is the JS:
$(document).ready()funciton(){
$('div.hoverbox').live('mouseenter mouseleave',function(e){
var isEnter = (e.type === 'mouseenter');
$(this).css('backgroundColor', isEnter ? 'red' : 'blue');
});
});
Here is the HTML:
<div class="hoverbox" style="height:100px;width:100px;">Hello World!</div>
The code does not work properly when binding multiple events. If I restructure the code and perform one event at a time, it works perfectly. Does .live() really support the binding of multiple events? Your help would be appreciated here.
Thanks,
Preston