How do I clear the content of a div using JavaScript?
css, html, javascript
Solution
Just Javascript (as requested)
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("");
Problem
When the user clicks a button on my page, the content of a div should be cleared. How would I go about accomplishing this?