【问题标题】:Fade effect when mouse over and out [closed]鼠标悬停时的淡入淡出效果[关闭]
【发布时间】:2015-10-16 21:36:35
【问题描述】:
我需要在鼠标悬停和移出时添加淡入淡出效果。
$(document).ready(function(){
$("#txtchange").mouseover(function (){
$('#txtchange').text("My New Txt");
});
$("#txtchange").mouseout(function (){
$('#txtchange').text("Old Txt");
});
});
【问题讨论】:
标签:
javascript
mouseover
mouseout
【解决方案1】:
试试下面的代码
$(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();
});
});
});
【解决方案2】:
你可以使用jquery函数fadeIn()。
$(document).ready(function(){
$("#txtchange").mouseover(function (){
$('#txtchange').text("My New Txt").fadeIn( "slow" );
});
$("#txtchange").mouseout(function (){
$('#txtchange').text("Old Txt").fadeIn( "slow" );
});
});