2012-05-09 131 views
0

我有一個wordpress網站,當一個表格被填寫,如果錯誤被拋出然後該插件顯示一個<span>與錯誤文本內。懸停jQuery fadeout元素

我試着去淡出文本出來使用jQuery和我曾嘗試以下兩個無濟於事......

$(".wpcf7-not-valid-tip").on("mouseenter", function(){ 
     alert('test'); 
}); 
$('.wpcf7-not-valid-tip').hover(
     function() { 
     $(this).fadeOut(); 
}); 

我的HTML標記被輸出爲使...

<span class="wpcf7-form-control-wrap telno"> 
    <input type="text" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required field wpcf7-not-valid" value="" name="telno"> 
    <span class="wpcf7-not-valid-tip">Please fill the required field.</span> 
</span> 
+0

似乎很好地工作:http://jsfiddle.net/j08691/SybUV/ – j08691

+0

正好!剛剛檢查小提琴,沒​​事的 –

+2

文檔準備好後事件是否被綁定?如果不是,它可能沒有被束縛。嘗試使用$('。wpcf7-not-valid-tip')。live('mouseenter',function(){// whatever}) – benastan

回答

0

是否有可能在物品存在之前綁定事件?

試試這個,看看如果你有更多的運氣

$('.wpcf7-not-valid-tip').live('mouseenter', function(ev) { 
    $(this).fadeOut(); 
}); 

$(".wpcf7-not-valid-tip").on("mouseenter", function(ev){ 
    $(this).fadeOut(); 
}); 
+0

我想你在回答問題時在你的問題中增加了'.on'示例。 – Dutchie432