tags:

views:

914

answers:

3

I have this java code:

<script src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
<script type="text/javascript">
google.load("jquery", "1.2.6");

$("a#more").click(function() {

$("#info_box").show("blind", { direction: "vertical" }, 800);

});
</script>

And this link:

<a href="#" id="more">More Info...</a>

info_box is just a div with the properties:

width: 30%;
position: absolute;
left: 35%;
top: 250px;
background-color: #FFFFFF;
border: 2px solid #000000;
visibility: hidden;

How can this not be working, been trying to figure it out for 20 minutes.

+1  A: 

Are you sure you're calling the right function? According to the docs at http://docs.jquery.com/Effects/show the show function takes a speed as the first parameter, and a callback function as the second. Your "blind" and { direction: "vertical" } are misplaced I think.

Also worth checking there's no conflict with another script e.g. mootools.

DisgruntledGoat
I'm only using jQuery and it is not a problem with the function as$("#info_box").show();doesn't work either.
zuk1
+4  A: 

You may use the ready() function and display: none in the initial CSS

Working HTML:

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(
    function()
    {
            $("a#more").click(function() {
                $("#info_box").show("blind");
            });
});
</script>
<style>
    #info_box {
        width: 30%;
        position: absolute;
        left: 35%;
        top: 250px;
        background-color: #FFFFFF;
        border: 2px solid #000000;
        display: none;}
</style>
</head>
<body>

<a href="#" id="more">More Info...</a>

<div id="info_box">Secret info goes here</div>


</body>
</html>

There are problems with the show function also. You are using a not documented params. Use the "animate" function instead to do a custom animation.

I also recommend you to use Firebug to troubleshot javascript problems in the future.

Eduardo Molteni
A: 

I had the exact same problem. You need to load the jQuery ui plugin as well as normal Jquery to use the format you have there.

Stacia