2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

Change an element's class with JavaScript

How can I change a class of an HTML element in response to an onClick event using JavaScript?
userimage

If you are using Javascript then below script will help to change the class name at the time of onClick event.

 <script>
          function modifyClass(){
              document.getElementById("change").setAttribute("class","anotherClass");

          }
</script>  

Answer is