I want that part 1 onclick div style changes and part 2 again on click it comes back to normal. I tried doing so but I failed to achieve the
part 1
part 2
Better change the class of the element (.regular is black, .alert is red):
function abc(){ var myDiv = document.getElementById("test"); if (myDiv.className == 'alert') { myDiv.className = 'regular'; } else { myDiv.className = 'alert'; } }