jQuery Page Widget How to - Change opacity for div without class








Question

We would like to know how to change opacity for div without class.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){<!-- w  w  w  .jav a  2s .  c o  m-->
    $('div:not(.nike)').css('opacity','0.2')
});//]]>  
</script>
</head>
<body>
  <div>1</div>
  <div>2</div>
  <div class="nike">3</div>
  <div>4</div>
</body>
</html>

The code above is rendered as follows: