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.
我在 jquery mobile 中有一个页面,我使用 HTML 动态填充每个 Javascript。
如果用户转到另一个页面,我想从页面中清除动态添加的 html 内容。
使用该.remove()方法,整个页面将从 Web 应用程序中删除。
.remove()
empty()只需在data-role="content"DIV上使用函数并在pagehide活动期间执行此操作。
empty()
data-role="content"
pagehide
工作示例:
$(document).on('pagehide', '#index', function(){ $('[data-role="content"]').empty(); });
在这种情况下#index是一个页面 id。
#index