user354355 user354355 - 1 month ago 8
HTML Question

Remove the contents under classname using Javascript

I want to remove the everything under the classname: social-share using JavaScript

HTML: This is what it looks like when I grab the code from chrome inspector.

<div class="social-share">
[shareaholic app="share_buttons" id="26444890"]
</div>


HTML: This is what exactly looks like inside the chrome inspector

<div class="social-share">
"
[shareaholic app="share_buttons" id="26444890"]
" == $0
</div>

Answer Source

You can use innerHTML to clear the contents of the element after it has been selected:

// select element with class 'social-share:
var social_share = document.querySelector('.social-share');

// Set it's contents to an empty string
social_share.innerHTML = '';