-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
  • 27,717
  • 28
  • 128
  • 190

1 Answers1

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