jQuery 1.4.2 - is $(“#foo”).hide(“normal”) broken or am I crazy?

前端 未结 4 589
情歌与酒
情歌与酒 2021-01-12 18:59

Does anyone know why .hide(\"normal\") does not seem to be working in jQuery 1.4.2? Is it a bug, has it been removed or am I just crazy? I\'ve managed to duplic

相关标签:
4条回答
  • 2021-01-12 19:17

    Problem is the class selector: .text != class="test"

    I've done that well over 100 times, with the same words :)

    Change to: $("div.test").hide("normal"); for a fix.


    Update: It seems jQuery UI 1.8 is the issue, breaking "normal" as an animation speed.

    This is from the jQuery UI forums:

    Thanks for pointing that out. Normal was actually never a valid speed option, it was a myth from invalid documentation (used to exist in jQuery core docs as well). The only reason that it worked is because invalid values fall back to the default speed.

    So it seems at least this member of the jQuery UI team doesn't think this is a breaking change, I strongly disagree and hope this is reversed in the next update.

    0 讨论(0)
  • 2021-01-12 19:21

    Work's for me... you are wrapping:

    $("button").click(function() {
         $("div.test").hide("normal");
    });
    

    in $(document).ready() aren't you?

    0 讨论(0)
  • 2021-01-12 19:23

    Is "normal" even an option for the speed? I thought slow, fast and a time in milliseconds were the only options.

    http://api.jquery.com/hide/

    0 讨论(0)
  • 2021-01-12 19:32

    Thank you for all the responses. In my question, I included what I thought was the relevant markup. However, unexpectedly and rather disturbingly, it is the inclusion of the latest jQuery UI (1.8.0) that is breaking "normal". Run the below, it will not work. Comment out the jQuery UI inclusion, and lo and behold, it will work!

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
    
    <script type="text/javascript">
        $(document).ready(function() {
            $("button").click(function() {
                 $("div.test").hide("normal");
            });
        });
    
    </script>
    </head>
    
    <body>
        <div class="test">Hello this is a test</div>
        <button>Click</button>
    </body>
    </html>
    
    0 讨论(0)
提交回复
热议问题