2016-08-14 62 views
2

我有一個腳本,執行一些功能來隱藏標題標記。這適用於使用mixitup插件的初始頁面加載。但是,如果使用排序功能,腳本將停止工作並顯示標題標記。jQuery的功能不工作,混合排序完成後

即使在混合排序完成後,我也想運行該功能。以下是腳本,我用它來隱藏鼠標懸停的標題標籤。

<script type="text/javascript"> 

$(document).ready(function(){ 
    $("a") 
     .mouseenter(function() {  
      var title = $(this).attr("title"); 
      $(this).attr("tmp_title", title); 
      $(this).attr("title",""); 
     }) 
     .mouseleave(function() { 
      var title = $(this).attr("tmp_title"); 
      $(this).attr("title", title); 
     }) 
     .click(function() { 
      var title = $(this).attr("tmp_title"); 
      $(this).attr("title", title); 
     }); 
    }); 
    </script> 

請幫我解決這個問題。

回答

0

我認爲你的事件通過你的排序被刪除。這應該工作:

$(document).ready(function(){ 
    $(document).on({ 
     mouseenter: function() {  
      var title = $(this).attr("title"); 
      $(this).attr("tmp_title", title); 
      $(this).attr("title",""); 
     }, 
     mouseleave: function() { 
      var title = $(this).attr("tmp_title"); 
      $(this).attr("title", title); 
     }, 
     click: function() { 
      var title = $(this).attr("tmp_title"); 
      $(this).attr("title", title); 
     } 
    }, "a"); 
}); 
+0

太棒了! ..謝謝你。維斯..你的解決方案幫助我解決了這個問題。再次感謝。 :) – Gops