javascript - jQuery how to achieve a toggleClick functionality -
i have div section hide/show based on clicking button. , i'm using jquery code show/hide divs based on clicking "pop-design1", "pop-design2", "pop-design3" buttons.
when 'pop-design1' button clicked once shows div. want achieve when clicked again opposite of script.
i think jquery had function toggleclick once achieve deprecated now.
thanks time
thanks
instead of removeclass()
or addclass()
, use toggleclass()
, instead of css('display',...)
use .toggle()
$('.pop-design1').click(function(){ $(".design-preview li:not(.design-preview2).selected").removeclass('selected'); $(".design-list li:not(.design-list2).selected").removeclass('selected'); $(".design-preview2").toggleclass('selected'); $(".design-list2").toggleclass('selected'); $(".overlay").toggle(); });
Comments
Post a Comment