Move div onclick and back onclick
问题 I have a jQuery code that moves a certain div element on right as I click it, i'd like to move it back to its original position when I click back on it. $(document).ready(function() { $("#wel1").click(function() { $("#sidemenu").animate({left: "80px"}); }); }); Give me a simple example of how to achieve it? 回答1: One possible way to achieve it is to store the state in a variable and check its state on click. $(document).ready(function() { var sideMenu = false; $("#wel1").click(function() { if