1. Access DOM Elements on the basis of class
This will return an array of result matching the class. As classes in DOM could be more than once hence we will always get the array.
2. Read the input field value
3. Add CSS styling to DOM elements
document.getElementsByClassName(‘classname’).style.backgroundColor = “red”;
4. Add/remove/append classes in DOM
document.getElementsById(‘classname’).className = “newClassName”;
Here is the running code — enjoy!!
Thank you guys for reading it. I would love to hear your thoughts on same. If you are a jslovers do not forget to join — meetup.com/jslovers.