我正在编辑 <div>
中的内容.现在我想检查<div>
中的数据是否是否已编辑,如果已编辑,则将其保存在 session 中并在刷新时返回。
如何检查数据是否被编辑,然后保存到session中?
以下是 Edit 的 JS fiddle 。
如果需要更多信息,请告知。
感谢您的帮助。
最佳答案
一个简单的解决方案是
点击编辑保存div内容。
data = $(this).siblings('.panel-title').html();
在点击完成时比较保存的内容和当前内容。
data != $(this).siblings('.panel-title').html()
如果它被编辑然后简单地store into the cookie或 localstorage .
- 如果您谈论的是服务器 session ,那么您可以进行 ajax 调用,服务器端应用程序将负责将数据保存到 session 中。
类似于 this .
关于javascript - 检查div中的数据是否被编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22854732/