Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2012-03-12
4
Medium Priority
?
180 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:shampouya
  • 2
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
ansudhindra earned 2000 total points
ID: 37712521
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.
0
 

Author Comment

by:shampouya
ID: 37712751
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";
0
 
LVL 13

Expert Comment

by:ansudhindra
ID: 37713284
I personally prefer using jQuery method as there will be a uniformity in coding.
0
 

Author Closing Comment

by:shampouya
ID: 37718486
thanks!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question