-1

Hello is there any way to edit html tag class name from script? For example:

html:

<div id="ThisIsId" class= "ThisIsName"> ... </div>

Script:

<script>
document.getElementById("ThisIsId").changeClassName("thisIsNewClassName") 
</script>
Liam
  • 25,247
  • 27
  • 110
  • 174

1 Answers1

0
<script>
document.getElementById("ThisIsId").classList.remove("ThisIsName").add("thisIsNewClassName") 
</script>
Vivek Gondhiya
  • 140
  • 2
  • 12