Set multiple css values

Description

The following code shows how to set multiple css values.

Example


<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--from   w  w w.j  a va2  s.  c  om-->
    $("b").hover(function() {
      $(this).css({
        'background-color' : 'yellow',
        'font-weight' : 'bolder'
      });
    }, function() {
      var cssObj = {
        'background-color' : '#ddd',
        'font-weight' : '',
        'color' : 'red'
      }
      $(this).css(cssObj);
    });
  });
</script>
</head>
<body>
  <b>java 2s.com</b>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities