$(document).ready(function () {
$("#button").toggle(function () {
$("#preview").animate({
height: 940,
width: 940
}, 800);
$("#button").replaceWith('<div id="button" style="margin:50px">Close</div>');
}, function () {
$("#preview").animate({
height: 500,
width: 500
}, 800);
$("#button").replaceWith('<div id="button" style="margin:0px">Open</div>');
});
});
This makes the preview screen change size and changes the button, however it does not execute the second part of the toggle, which would be resize the preview back and change the button's value to the original state (Open).
Any idea how to fix this?