philchanet
11/24/2016 - 11:49 AM

Show / hide element depending on the presence of another element The element must me hidden by default in css

Show / hide element depending on the presence of another element The element must me hidden by default in css

document.addEventListener("DOMContentLoaded", function(event) {
    if (document.querySelector(".article-marker-tag")) {
        var msg = document.getElementById('section-social-links');
        msg.style.display = "block";
    }
});
<div id="section-social-links">
  <div class="article-marker-tag">Article content</div>
</div>
#section-social-links {
  display: none;
}