javascript - How to remove the content from a "div" element using a button "onclick" function? -
i have div
element contains number of images. when user clicks button, want contents of div
removed (not div
itself, want reuse div
potentially add new content).
in html, div
, button
defined as:
<body> ... <div class="mydiv"></div> ... <button id="removediv" onclick="removedivfunction()">remove div function</button> ... </body>
how write function removes elements div
?
you have call removechild
:
function removedivfunction() { mydiv.parentnode.removechild(mydiv); }
Comments
Post a Comment