完成mixitup排序后,Jquery函数无法正常工作

时间:2016-08-14 11:52:27

标签: javascript jquery mixitup

我有一个脚本可以执行一些隐藏标题标记的功能。这在初始页面加载时工作正常,其中使用了mixitup插件。但是,如果我使用sort函数,脚本将停止工作并显示标题标记。

我想运行该函数,即使在完成mixitup排序之后也是如此。以下是脚本,我用来在鼠标悬停时隐藏标题标签。

<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>

请帮我解决这个问题。

1 个答案:

答案 0 :(得分: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");
});