We help IT Professionals succeed at work.

Why does my javascript statement stop working once I use jquery?

shampouya
shampouya asked
on
This line in my js file seems to stop working if I try to change my website color from pink to purple (see webpage below):

      document.getElementById("submit").className = 'formButtonPurple';

http://www.pouyarebek.com/wdiclass/assignment4/homework4.html
Comment
Watch Question

you are setting the background-color property of the button in the other 2 functions to pink and blue.

Setting individual styles (or inline styles) gets preference over the css class.

If you try to update the background-color to purple it works check it.

Author

Commented:
Ok these two ways seem to work now. Is there no difference between these two in terms of which one gets preference?

      $(".formButton").css("background-color", "#5959ff");
      document.getElementById("submit").style.background = "#5959ff";
I personally prefer using jQuery method as there will be a uniformity in coding.

Author

Commented:
thanks!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.