Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2012-03-12
4
171 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 500 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to delete "dots" above Bootstrap 3 navbar 4 51
parse url to form? 7 25
binding event to form in window.open 9 35
2 separate CSS animations 2 16
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

790 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