Tuesday 15 September 2015

javascript - How to switch to quoted class name -


I am trying to switch a class with javascript. This is

  class = product neutral // background color is gray   

this

  class = product right / / Background color is green if (trueProduct == 12) {document.getElementById ("userAnswer"). InnerHTML = "class = 'product correct'"; }   

HTML

  & lt; Span id = "userAnswer" class = "product neutral" & gt; & Lt; / Span & gt; Use    

, the most convenient here.

  var Reply = document.getElementById ("userAnswer"); Answer.classList.remove ("neutral"); Answer.classList.add ('true'); Permission for   

classlist you toggle or add or delete Gives special class without changing any other.

No comments:

Post a Comment