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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -