// JavaScript

Destroying objects by class

If you want to remove elements in an HTML page based on a specific class using JavaScript, you can use the following JavaScript code.

var elements = document.getElementsByClassName(className);
for(var i = 0, length = elements.length; i < length; i++) {
   if( elements[i].textContent == 'ClassIsmi'){
      elements[i].style.display = 'none';
   } 
}

 

// FEEDBACK

Was this useful?

Your rating shows how helpful this note is to other readers.

Was this useful?

Click the stars to rate.

Average rating 0 / 5. Total votes: 0

No one has rated this post yet. Be the first!

Sorry this post was not helpful.

Your feedback is valuable to us.

How can we make this post more helpful?

// JOIN THE CONVERSATION

Share your experience

Got a question, a different solution or a note to add?

// KEEP READING

One more note.

All posts ↗︎