user354355 user354355 - 6 months ago 29
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"]

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

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

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 = '';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download