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.
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");
});