jQuery Style How to - Set Outline for div








Question

We would like to know how to set Outline for div.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<style type='text/css'>
div {<!-- ww  w  . j  a va2s  .c  o  m-->
  height: 100px;
  margin: 10px;
  background: yellow;
}
</style>
<script type='text/javascript'>
$(function(){
    $('div').css({'outline': '5px solid blue'});
});
</script>
</head>
<body>
  <div></div>
</body>
</html>

The code above is rendered as follows: