一次使用多種事件的方式 (中間以空白間隔開) Multiple event types can be bound at once by including each one separated by a space $(‘#foo’).bind(‘mouseenter mouseleave’, function() { $(this).toggleClass('entered'); });
the default behavior of an event to occur (such as a form submission). 此方法不會處發事件的預設行為,例如表單的submit While .trigger() will operate on all elements matched by the jQuery object,.triggerHandler() only affects the first matched element. Trigger會運作在所有的元素,但triggerHander()只會作用在第 一個符合的元素 Events created with .triggerHandler() do not bubble up the DOM hierarchy; if they are not handled by the target element directly, they do nothing. triggerHander( )不會將事件往上傳遞。 Instead of returning the jQuery object (to allow chaining), .triggerHandler() returns whatever value was returned by the last handler it caused to be executed. If no handlers are triggered, it returns undefined 如果沒有事件函數被觸發,trigger會回傳undefinde
data, handler(eventObject) ) .live( events-map ) As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live(). 在1.7的版本中,live( )方法已經過時了(淘汰)。使用.on( )去附加事件。 舊版的用戶應該更優先使用.delegate()勝過.live()
handler(eventObject) ) .undelegate( selector, events ) .undelegate( namespace ) The .undelegate() method is a way of removing event handlers that have been bound using.delegate(). Undelegate()方法是用來移除delegate()的函式。 As of jQuery 1.7, the .on() and .off() methods are preferred for attaching and removing event handlers. 在jQuery中,.on()跟.off()是用來附加或移除事件處理函式的首選。
to an element where the context is pointing back to a different object. Additionally, jQuery makes sure that even if you bind the function returned from jQuery.proxy() it will still unbind the correct function if passed the original. 這個用法多半有用再將物件處理程序綁定在一個元 素,此元素的內容另外指向一個不同的物件