有人可以告诉我什么分配事件处理程序之间的区别使用绑定():分配事件处理程序与jQuery中的bind()和each()之间的区别?
$(function(){
$('someElement')
.bind('mouseover',function(e) {
$(this).css({
//change color
});
})
.bind('mouseout',function(e) {
$(this).css({
//return to previous state
});
})
.bind('click',function(e) {
$(this).css({
//do smth.
});
})
});
,并使用每个()完成同样的任务:
$('someElement').each(function(){
$(this).mouseover(function(){$(this).css({/*change color*/})
.mouseout(function(){$(this).css({/*return to previous state*/});
});
});
});
谢谢。
你的第二个例子是不是证明了“每个”方法。只是让你知道... – KyleFarris 2009-04-16 15:05:27
哦,我会修复。 ty – chosta 2009-04-16 15:10:16