js中的hover,可以写成
$('#sid').hover(function(){
//
}, function(){
//
});
但对于动态加载的元素,写成
$('#sid').live('hover', function(){
//
}, function(){
//
});
就不对了。这是因为hover不是click这样的事件,而是.mouseenter(handler1).mouseleave(handler2)的简写。所以,可以写成:
$("#sid").live('mouseenter', function() {
//
}).live('mouseleave', function () {
//
});
在1.4.2中,变成.live('mouseover mouseout')。1.4.3+中,可以写成
$("#sid").live({
mouseover: function() {
//
},
mouseout: function () {
//
}
});