Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Toggle to display has closed WordPress

  • SOLVED

Hello,

I have a toggle that display has open state, I want it to be closed when the page is load.
The user then click on a button to open it.

Here is the code I use :

/*-----------------------------------------------------------------------------------*/
/* Toggle
/*-----------------------------------------------------------------------------------*/

$(".close").click(function () {
$(".info-content").toggle("blind", {}, 1000);
$(this).toggleClass("active").next().slideToggle("slow");

});

Answers (2)

2014-02-26

Hariprasad Vijayan answers:

Hello,
Call ".close" click on page load.
$(".close").click();


guillaume guillaume comments:

can you develop the whole code for me please ?


Hariprasad Vijayan comments:

Code would be like this

/*-----------------------------------------------------------------------------------*/
/* Toggle
/*-----------------------------------------------------------------------------------*/
$(".close").click(function () {
$(".info-content").toggle("blind", {}, 1000);
$(this).toggleClass("active").next().slideToggle("slow");
});
$(".close").click();


guillaume guillaume comments:

Ok, I try your code.
When the page load the toggle is open and then close.
I just need it to be close.


Hariprasad Vijayan comments:

okay. When we are doing it with jquery it will work like that.

Try following style in css.

.info-content {
display:none;
}


Can you show url?


guillaume guillaume comments:

It works, but there is no way to set up the toggle with a closed state ?


Hariprasad Vijayan comments:

Here, the toggle function is just changing the visibility of ".info-content" with some animation. The code "$(".close").click();" is changing its visibility on page load. But it only close after page load.

Same process is doing with css. Making ".info-content" invisible(Closed state) using css. It will always closed state when page load.


guillaume guillaume comments:

So I'll choose to use the CSS dispaly none.


Hariprasad Vijayan comments:

Yes.
<blockquote>
but there is no way to set up the toggle with a closed state ?
</blockquote>
Setting it to "Closed state" using css.

2014-02-26

Sébastien | French WordpressDesigner answers:


Sébastien | French WordpressDesigner comments:

Guillaume, do you see my responses ?


guillaume guillaume comments:

Yes, thank you