Gurami Nikolaishvili
Gurami Nikolaishvili

Reputation: 182

How to remove second class of html element in javascript?

I have multiple span tags. example:

<span class="name one"></span>
<span class="name two"></span>
<span class="name three"></span>
<span class="name four"></span>

how can i remove second class without using class name like span.classList.remove('three'); i just need something like span.classList.remove(1); to remove only second class from all span elements

Upvotes: 3

Views: 757

Answers (1)

Gurami Nikolaishvili
Gurami Nikolaishvili

Reputation: 182

I found answer

span.classList.remove(span.classList.item(1));

Upvotes: 2

Related Questions