css(properties): set several style properties on matched elements. : css function « jQuery « JavaScript DHTML






css(properties): set several style properties on matched elements.

 


<html>
  <head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){

                   $("p").hover(function () {
                      $(this).css({ backgroundColor:"yellow", fontWeight:"bolder" });
                    }, function () {
                      var cssObj = {
                        backgroundColor: "#ddd",
                        color: "rgb(0,40,244)"
                      }
                      $(this).css(cssObj);
                    });
        });
    </script>

  </head>
  <body>
    <body>
           <p>Move the mouse over me.</p>
                 
    </body>
</html>

   
  








Related examples in the same category

1.Add border to DIV
2.Add paragraph and set the style
3.Define CSS in an array and set
4.Get CSS value
5.Set two CSS value in CSS function
6.Nested style setting
7.Use the rgb function with JQuery
8.Use CSS value when creating new tag
9.The basic CSS Selectors supported by jQuery
10.css(name): Return a style property on the matched element.
11.css(name, value): If a number is provided, it is automatically converted into a pixel value.
12.Adds a background and text color to all the headers on the page.
13.Sets the background color of the page to black.