I have <div id="test"></div>and <a id="trigger"></a>. Div has width 300px. I want the div to re size it’s width to 100px when user click trigger and want to re size to previous size when user again click the trigger. How can i make this using jquery??
Thanks in advance…:)
blasteralfred
Assign a variable of 1 for click and 0 for unclick and then use the .click function as follows:
UPDATE – BETTER ANSWER
I made this suggestion awhile back; but believe there is a more elegant and pragmatic approach to solving this. You could use CSS transitions and have jquery simply add/remove a class that initiates the transition:
Working Fiddle:
https://jsfiddle.net/2q0odoLk/
CSS:
jQuery: