jQuery 事件 - mouseleave() 方法
實(shí)例
當(dāng)鼠標(biāo)指針離開(kāi)元素時(shí),改變?cè)氐谋尘吧?/p>
$("p").mouseleave(function(){ $("p").css("background-color","#E9E9E4"); });
定義和用法
當(dāng)鼠標(biāo)指針離開(kāi)元素時(shí),會(huì)發(fā)生 mouseleave 事件。
該事件大多數(shù)時(shí)候會(huì)與 mouseenter 事件一起使用。
mouseleave() 方法觸發(fā) mouseleave 事件,或規(guī)定當(dāng)發(fā)生 mouseleave 事件時(shí)運(yùn)行的函數(shù)。
注釋:與 mouseout 事件不同,只有在鼠標(biāo)指針離開(kāi)被選元素時(shí),才會(huì)觸發(fā) mouseleave 事件。如果鼠標(biāo)指針離開(kāi)任何子元素,同樣會(huì)觸發(fā) mouseout 事件。請(qǐng)看下面例子的演示。
將函數(shù)綁定到 mouseleave 事件
語(yǔ)法
$(selector).mouseleave(function)
參數(shù) | 描述 |
---|---|
function | 可選。規(guī)定當(dāng)發(fā)生 mouseleave 事件時(shí)運(yùn)行的函數(shù)。 |