2

I have a script that does some function to hide a title tag. This works fine on the initial page load, where a mixitup plugin is used. However, if I use the sort function, the script ceases to work and the title tag is displayed.

I want to run the function, even after the mixitup sorting is done. The following is the script, I use to hide the title tag on mouseover.

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

Please help me to solve this issue.

Gops
  • 687
  • 2
  • 7
  • 20

1 Answers1

0

I think your events are removed by your sorting. This should work:

$(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");
});
Veas
  • 160
  • 8
  • Fantastic! .. Thank you Veas .. Your solution helped me to solve the issue. Thanks again. :) – Gops Aug 15 '16 at 04:18