[英]HTML JavaScript- how to empty contents of div which holds local storage
How can i empty the contents of div=history. 我如何清空div = history的内容。 This div is used to display local storage, once the 'clear button is clicked i would like that page to clear. 单击“清除”按钮后,此div用于显示本地存储,我想清除该页面。 Can anyone advise me? 谁能告诉我?
<button onclick="click_button_clear()">Clear</button>
<div id="history"></div>
function click_button_clear() {
window.localStorage.clear();
}
sorted 已排序
function click_button_clear() {
jQuery("#history").empty();
}
If you can make use of jQuery, otherwise: 如果可以使用jQuery,否则:
function click_button_clear() {
document.getElementById(history).innerHTML = "";
}
You can do like below in Jquery: 您可以在Jquery中执行以下操作:
function click_button_clear()
{
$('#history').html('');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.