Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jquery

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 duplicate this using several different scenarios. Just try this:

<!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>
like image 432
karim79 Avatar asked Apr 05 '10 11:04

karim79


People also ask

Is jQuery installed?

You can test if jQuery is loaded by opening your javascript console (in Chrome: Settings > More tools > Javascript console). Where the little blue arrow appears type: if(jQuery) alert('jQuery is loaded'); Press enter.

What is jQuery min JS?

jquery. min. js is a compressed version of jquery. js (whitespaces and comments stripped out, shorter variable names, ...) in order to preserve bandwidth. In terms of functionality they are absolutely the same.


2 Answers

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.

like image 57
Nick Craver Avatar answered Oct 10 '22 20:10

Nick Craver


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

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

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

like image 34
Matt Avatar answered Oct 10 '22 20:10

Matt