Set DIV color : DIV « jQuery « JavaScript DHTML






Set DIV color

     

<html>
  <head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
           $("div").css("color", "red").add("p").css("background", "yellow");
        });
    </script>
    <style>
      div { width:40px; height:40px; margin:10px; float:left;}
    </style>
  </head>
  <body>
    <body>

          <div>asdf</div>
          <div>asdf</div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
  </body>
</html>

   
    
    
    
    
  








Related examples in the same category

1.Append to DIV
2.Change DIV background
3.Click to add border
4.Click to change DIV tag color
5.Get text from paragraph and set to DIV
6.Fade div to a random opacity on each click, completing the animation within 200 milliseconds.
7.Animates all divs to slide down and show themselves over 600 milliseconds.
8.Animates divs between dividers with a toggle that makes some appear and some disappear.
9.Sets id for divs based on the position in the page.
10.Bind a single click that adds the div id to its text.
11.Add html to div then do further manipulations to the inserted html.
12.Turn the div with index 2 blue by adding an appropriate class.
13.Change the color of all divs then put a border around only some of them.
14.Change the color of all divs then put a border two specific ones.
15.Adds a border to divs that are not green
16.Finds all divs adds all paragraphs
17.Find all children of each div.
18.Locate all the divs after the first and give them a class.
19.Tie a one-time click to each div.
20.Hides the divs when clicked over 2 seconds, then removes the div element when its hidden.
21.To set the width of each div on click to 30px plus a color change.
22.To set the height of each div on click to 30px plus a color change.
23.Wrap a jQuery object div around all of the paragraphs
24.Animates all hidden divs to show fastly in order
25.Hides the divs when clicked, then removes the div element when its hidden.
26.Creates a div element (and all of its contents) dynamically, and appends it to the body element.
27.Bind mouse over and out event to div tag
28.Switch class when clicking the div tag