Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
155
rated 0 times [  162] [ 7]  / answers: 1 / hits: 49765  / 11 Years ago, wed, december 11, 2013, 12:00:00

How can I show and hide a div (content) with a click on a button?



Here some code:



<button class=btn btn-default>Text</button>
<div class=div-to-hide>Some content</div>

More From » jquery

 Answers
10

You can do this by using jQuery's toggle function like <button class=button onclick=$('#target').toggle();>Show/Hide</button>



Here is a working example: http://jsfiddle.net/W2vh3/


[#73782] Tuesday, December 10, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alorac

Total Points: 262
Total Questions: 82
Total Answers: 97

Location: Libya
Member since Mon, Dec 7, 2020
4 Years ago
alorac questions
Sat, Oct 10, 20, 00:00, 4 Years ago
Tue, Sep 22, 20, 00:00, 4 Years ago
Wed, Jul 1, 20, 00:00, 4 Years ago
Wed, Jun 3, 20, 00:00, 4 Years ago
Sun, May 17, 20, 00:00, 4 Years ago
;