Skip to content Skip to sidebar Skip to footer

Slideup Slidedown

i have this javascript code: var x='#wrapper' //var xyz; $(document).ready(function(){ $('#about').click(function(){ if (!(x=='#about')){ $(x).slideUp('slow',funct

Solution 1:

In the last line of your code, set x to #wrapper not dd:

var x="#wrapper"//var xyz; 
$(document).ready(function(){

    $("#about").click(function(){
        if (!(x=="#about")){
            $(x).slideUp("slow",function(){
                $("#aboutus").slideDown("slow");
            });
            x="#aboutus";
        }
    });

    $("#home").click(function(){ 
        if(!(x=="#wrapper")){
            $(x).slideUp("slow", function(){
                $("#wrapper").slideDown("slow");
            });
            x="#wrapper";
        }

    }); 
});

Solution 2:

I came on this nice one a while ago. It is simple and works.

functiontoggleForm(x) {
        if ($('#'+x).is(":hidden")) {
            $('#'+x).slideDown(200);
        } else {
            $('#'+x).slideUp(200);
        }
}

Then to call it ...

onmousedown="javascript:toggleForm('div_ID');

and to not change your URL add this in front on the same call

onclick="return false"

with this, you can use one script to call as many slid operations as you want. The div to be targeted is the one that has its ID in the call.

EDIT: sorry ... Just noted that it is jQuery, but should not affect anything. I used it where other jQuery did not. So does not seem to conflict anywere.

Post a Comment for "Slideup Slidedown"