Jump to content

jquery code. it works but seems weird


alapimba

Recommended Posts

Hi

 

I'm learning jquery and i have one doubt.

 

this code that i wrote with bits from here and there works fine

but i was looking at it and it seems like missing one });

 

Is this correct? (it works...)

 

<script type="text/javascript">
    $(document).ready(function() {
        $(".thumb").thumbs();
        });
///////////
    $(window).load(function(){
        $("li").each(function(index) {
            $(this).delay(300*index).fadeIn(600);
            });
        $("img").each(function(index) {
        $(this).delay(300*index).slideDown();
        });
//////////
        $("#go3").click(function(){
            $("li").each(function(index) {
                $(this).delay(100*index).hide("slow");
                });
            /*$("#lista").animate({
            width: "70em",
            marginLeft: "0",
            }, 1500 );*/
            });
/////////
        $("#go4").click(function(){
            $("li").each(function(index) {
                $(this).delay(100*index).fadeIn(600);
                });
            });
        });
</script>

Link to comment
https://forums.phpfreaks.com/topic/238798-jquery-code-it-works-but-seems-weird/
Share on other sites

If it works then it's syntactically correct or else JS craps out and stops working altogether.  Here is your code formatted to my preference so it's easier to read:

<br />
    $(document).ready(function()<br />
    {<br />
        $(".thumb").thumbs();<br />
    });<br />
    ///////////<br />
    $(window).load(function()<br />
    {<br />
        $("li").each(function(index)<br />
        {<br />
            $(this).delay(300 * index).fadeIn(600);<br />
        });<br />
        $("img").each(function(index)<br />
        {<br />
            $(this).delay(300 * index).slideDown();<br />
        });<br />
        //////////<br />
        $("#go3").click(function()<br />
        {<br />
            $("li").each(function(index)<br />
            {<br />
                $(this).delay(100 * index).hide("slow");<br />
            });<br />
/*$("#lista").animate({<br />
            width: "70em",<br />
            marginLeft: "0",<br />
            }, 1500 );*/<br />
        });<br />
        /////////<br />
        $("#go4").click(function()<br />
        {<br />
            $("li").each(function(index)<br />
            {<br />
                $(this).delay(100 * index).fadeIn(600);<br />
            });<br />
        });<br />
    });<br />

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.