How can I remove a footer element using Javascript -
i have html:
<footer class="footer"> <div class="container-fluid wrapper"> ... </div> </footer>
how remove whole footer markup using javascript (no jquery available)?
i've tried:
var elem = document.getelementsbyname("footer"); elem.remove();
...and couple of other variations, can't delete.
any ideas?
thanks, mark
yes, can this
function removetagbytagname(tagname) { var ele = document.getelementsbytagname(tagname); return ele[0].parentnode.removechild(ele[0]); }
function removetag(tag) { var ele = document.getelementsbytagname(tag); return ele[0].parentnode.removechild(ele[0]); } var btn = document.getelementbyid("delet"); btn.addeventlistener("click", function(){ removetagbytagname("footer"); });
<body> <button id="delet">delete footer!</button> <footer class="footer" name="footer"> <div class="container-fluid wrapper"> blab bal babla </div> </footer> </body>
Comments
Post a Comment