0

I have a slide up function on click, but once it is displayed i don't want it to slide up again once the user clicks on the link a second time, but I can't seem to get it to work.

According to answer iv'e read it was better to use .is hidden, but that doesn't seem to fix the problem.

$(document).ready(function() {
    if ($('#aboutpage').is(":hidden")) {
        $('.about').click(function() {
            $(divPages).slideUp(1000);
            $('#aboutpage').slideDown(1000);
        });
    }
});
2
  • that isn't really want I want. the click function makes a page slide up, with a close button, which once closed, i want them to be able to open it again. just that once its opened, if i click the .about while its opened it slides up and down with the same thing opened Commented Oct 19, 2012 at 1:44
  • 1
    It sounds like you are looking for toogle then? api.jquery.com/toggle-event Commented Oct 19, 2012 at 1:46

1 Answer 1

1

Is this what you want: Demo http://jsfiddle.net/R8WvF/ and your demo here http://jsfiddle.net/4meXU/ or more simpler: http://jsfiddle.net/rzqmT/

*Fixed your page by using the code patch updated below

Same button open and closes the slideUp and Down.

Hope it fits the cause :)

code

$("#toggleme").click(function(){
    $('.bnr').toggle(500);
});
​

another

$(document).ready(function() {
    $('.about').click(function() {
        if (!$('#aboutpage').is(":visible")) {
            $(divPages).slideUp(1000);
            $('#aboutpage').slideDown(1000);
        }else{
            $(divPages).slideDown(1000);
            $('#aboutpage').slideUp(1000);
        }
    });

});

or

var divPages = "#feed, #aboutpage"

$(document).ready(function() {
    $('.about').click(function() {
            $(divPages+', #aboutpage').slideToggle(1000);

    });

});
Sign up to request clarification or add additional context in comments.

4 Comments

It does what I want, but the issue is I need the background content to disappear. and I also want a slide up effect, rather than that toggle effect. Basically I need the function to work if the div = display none, and the function not to work if the div has a display of block.
@MaximSiebert Saweet bruv, can you please flick your html in my demo above I will help you out man :)
I'm not familiar with jfidde so I uploaded it to my host for you to check out. what I'm talking about is the about button, once you click it the about page slides up. and once up, if you click it again it causes something. maximsiebert.com/unamed/Untitled-1.html
@MaximSiebert Fixed :) jsfiddle.net/4meXU/show updating my post now!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.