Javascript Style How to - Set multiple css values








Question

We would like to know how to set multiple css values.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--   w  ww.j a  va 2s.com-->
$('#elementId').css({
    'height': '60px',
    'width': '268px',
    'display': 'block',
    'float': 'right',
    'background-color': 'red'
});
});
</script>
</head>
<body>
  <div id="elementId"></div>
</body>
</html>

The code above is rendered as follows: