html 如何清除JavaScript中的div,来自http://stackoverflow.com/questions/3450593/how-do-i-clear-the-content-of-

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 如何清除JavaScript中的div,来自http://stackoverflow.com/questions/3450593/how-do-i-clear-the-content-of-相关的知识,希望对你有一定的参考价值。

// Add this function somewhere on your page (preferably in the <head>)

function clearBox(elementID)
{
    document.getElementById(elementID).innerHTML = "";
}

// Then add the button on click event:
<button onclick="clearBox('cart_item')" />

// In JQuery (for reference)
// If you prefer JQuery you could do:

$("#cart_item").html("");

以上是关于html 如何清除JavaScript中的div,来自http://stackoverflow.com/questions/3450593/how-do-i-clear-the-content-of-的主要内容,如果未能解决你的问题,请参考以下文章