我有一个带有表格的DIV.当用户提交表单并成功提交时,我会用简单的"一切都很好"消息替换表单:
$("#some_div").html("Yeah all good mate!");
Run Code Online (Sandbox Code Playgroud)
是否有一种很好的方法可以根据已经到达的HTML将div"重置"为"原始状态"?我只能想到实际做这样的事情:
//before I change the DIV
var originalState = $("#some_div").html();
//manipulate the DIV
//...
//push the state back
$("#some_div").html(originalState);
Run Code Online (Sandbox Code Playgroud)
它看起来不是很优雅 - 我想有更好的解决方案,不是吗?