【问题标题】: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" );
        });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多