HTML JavaScript-如何清空包含本地存储的div的内容

时间:2016-04-03 10:56:04

标签: javascript jquery html local-storage

如何清空div = history的内容。此div用于显示本地存储,单击“清除”按钮后,我希望该页面清除。有人可以建议我吗?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <appnamespace.ui.android.extensions.DraggableListView
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/playerListView" />
</LinearLayout>

3 个答案:

答案 0 :(得分:0)

function click_button_clear() {
    window.localStorage.clear(); 
}

排序

答案 1 :(得分:0)

function click_button_clear() {
    jQuery("#history").empty(); 
}

如果你可以使用jQuery,否则:

function click_button_clear() {
    document.getElementById(history).innerHTML = ""; 
}

答案 2 :(得分:0)

您可以在Jquery中执行以下操作:

function click_button_clear()
{ 
    $('#history').html('');
}