Friday, 15 January 2010

javascript - jquery toggle height and change button value -



javascript - jquery toggle height and change button value -

i have div (#world) 500px height default. got button value "open" when click on button #world div should animate , decrease height of 200px @ same time button value alter "close".

need help :( i've googled can't understand how this. yes i'm newbie :)

is trying achieve?

demo: http://jsfiddle.net/frbhz/

$(document).ready(function() { $('button').click(function() { this.value = (this.value == 'open') ? 'close' : 'open'; var new_height = ($('#world').height() == 500) ? 200 : 500; $('#world').animate({ height: new_height }); }) });

javascript jquery toggle

No comments:

Post a Comment