Welcome Guest!

If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:

  • Receive Fast Advice
  • Learn Programming Languages
  • Get Professional Website Reviews
  • Quick Troubleshooting Assistance

> Jquery - Set Css Element

This is a discussion on Jquery - Set Css Element, within the Javascript section. This forum and the thread "Jquery - Set Css Element" are both part of the Frameworks category.

 
Reply to this topicStart new topic
> Jquery - Set Css Element
Jason
post Apr 29 2008, 07:24 AM
Post #1


Master of the Universe
******

Group: Advisors
Posts: 1,157
Joined: 15-February 08
From: London, England
Member No.: 141



I have looked at the documentation but am having a little difficulty pulling this one apart.

I want to set the background color to #000 on the following html using JQuery. Any ideas how this is done?

<div id="1"></div>


--------------------
Go to the top of the page
 
+Quote Post
c010depunkk
post Apr 29 2008, 11:18 AM
Post #2


Rapid Squeezer
****

Group: Advisors
Posts: 176
Joined: 14-February 08
From: Willich, Germany
Member No.: 56



All you need is two CSS classes:
CODE
.blue { background-color:#0000FF; }
.red { background-color:#FF0000; }

and the JQuery JS to change the CSS class:
CODE
$("#1").addClass("<blue or red>");

Not sure if an ID can start with a number.....


--------------------
www.c010depunkk.com ~ the hangout of a web developer
Go to the top of the page
 
+Quote Post
Rakuli
post May 6 2008, 07:33 AM
Post #3


Squeeze Machine
*****

Group: Administrators
Posts: 643
Joined: 13-February 08
From: Catching the squeezed drips downunder.
Member No.: 13



QUOTE
Not sure if an ID can start with a number.....


No and ID may not start with a number when dealing with the DOM .(W3 no no as well)


--------------------
Luke Dingle . com

Turn Over a Playful Leaf on Web Design -- read about the javascript cat
Go to the top of the page
 
+Quote Post
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   8 unitedcraig 426 9th September 2008 - 10:03 PM
Last post by: Monie
No New Posts   9 djeyewater 340 2nd June 2008 - 04:27 AM
Last post by: MikeHopley
No New Posts   6 djeyewater 183 9th June 2008 - 05:18 AM
Last post by: unitedcraig
No New Posts   10 MikeHopley 815 21st June 2008 - 07:40 PM
Last post by: karinne
No new   19 jackfranklin 452 21st June 2008 - 07:39 PM
Last post by: karinne