Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要能够恢复 div 中的 HTML 代码,因为它已准备好页面。我需要这个,因为我想在页面准备好后对 HTML 代码进行一些更改,然后在我需要时将其恢复为页面准备就绪的方式..
我正在考虑使用克隆,但是如何只复制 div 的内容而不粘贴呢?我需要在准备好页面时复制 div 的内容,然后在需要时将其粘贴/替换为原始 div..
我对 jquery 比较陌生,我尝试了几件事但没有运气,我找不到我需要的东西。感谢您的任何建议!
您可以将其复制到变量中以备后用。
var originalContent; $(document).ready(function() { originalContent = $('#theDiv').clone(); });