I have a DOM as shown below in which I want to hide specific h2 tag contents.
All of them have the same class shows-list__title. The contents are at Line A (Vote 2015 Phone-in), Line B(Vote 2015 Phone-in) and Line C (Vote 2015 Special).
<li class="shows-list__letter">
<h1 class="shows-list__letter-title">V</h1>
<a class="shows-list__link" href="http://sandbox.cpac.ca/en/programs/vote-2015-debates/">
<h2 class="shows-list__title">Vote 2015 Debates</h2> <!-- Line A -->
</a>
</li>
<li class="shows-list__letter">
<a class="shows-list__link" href="http://sandbox.cpac.ca/en/programs/vote-2015-phone-in/">
<h2 class="shows-list__title">Vote 2015 Phone-in</h2> <!-- Line B -->
</a>
</li>
<li class="shows-list__letter">
<a class="shows-list__link" href="http://sandbox.cpac.ca/en/programs/vote-2015-special/">
<h2 class="shows-list__title">Vote 2015 Special</h2> <!-- Line C -->
</a>
</li>
<li class="shows-list__letter">
<a class="shows-list__link" href="http://sandbox.cpac.ca/en/programs/voting-reform/">
<h2 class="shows-list__title">Voting Reform</h2>
</a>
</li>
Problem Statement:
I am wondering what JS code I need to add so that it hides Vote 2015 Debates , Vote 2015 Phone-in and Vote 2015 Special from the DOM/webpage. I don't want to hide that h2 tag which has content Voting Reform.
var elementList = document.querySelectorAll("h2"); elementList.forEach((element) => {element.style = "display: none;";});shows-list__title. And iterate the returned node list with either css or html hidden attributeVote 2015 Debates,Vote 2015 Phone-inandVote 2015 Special.