有人可以告訴我什麼分配事件處理程序之間的區別使用綁定():分配事件處理程序與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