I frequently see code like that:
$("#foo").live("mouseover mouseout", function(e) {
if (e.type == "mouseover") {
$("#foo").append("<div id='bar'>");
} else {
$("#bar").remove();
}
});
instead of more self-explanatory in my opinion:
$("#foo").live("mouseover", function(e) {
$("#foo").append("<div id='bar'>");
})
.live("mouseout", function(e) {
$("#bar").remove();
});
the same goes with
$('#contentPageID, #itemURL').change ( function () {
if ( $(this).is('#contentPageID') )
...
else
...
});
does it have any purpose or is it just different coding style (counter intuitive in my point of view) ?
.live
:( use.bind
or.delegate
. Never.live
– Raynos Aug 8 '11 at 8:11