2015-10-16 137 views
0

我需要在鼠标悬停和拖出时添加淡入淡出效果。鼠标悬停和退出时的淡入淡出效果

$(document).ready(function(){ 
    $("#txtchange").mouseover(function(){ 
     $('#txtchange').text("My New Txt"); 
    }); 
    $("#txtchange").mouseout(function(){ 
     $('#txtchange').text("Old Txt"); 
    }); 
}); 

回答

0

尝试用下面的代码

$(document).ready(function(){  
     $("#txtchange").mouseover(function(){ 
      $("#txtchange").fadeOut(function() { 
      $(this).text("My New Txt").fadeIn(); 
      }); 
     });  
     $("#txtchange").mouseout(function(){ 
      $("#txtchange").fadeOut(function() { 
      $(this).text("Old Txt").fadeIn(); 
      }); 
     });  
    }); 
+0

作品! amzing谢谢。 – Revolution

0

您可以使用jquery函数fadeIn()

$(document).ready(function(){ 
    $("#txtchange").mouseover(function(){ 
     $('#txtchange').text("My New Txt").fadeIn("slow"); 
    }); 
    $("#txtchange").mouseout(function(){ 
     $('#txtchange').text("Old Txt").fadeIn("slow"); 
    }); 
});