jQuery Selector How to - Select elements with class except one with specific id








Question

We would like to know how to select elements with class except one with specific id.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.3.js'></script>
<style type='text/css'>
div {<!--  w w w . ja  va  2 s  .c  o m-->
  border: 1px solid red;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    $('.ui-widget-content').not('#helpDialog').css('border','none');
});
</script>
</head>
<body>
  <div class="ui-widget-content">test1</div>
  <div class="ui-widget-content" id="helpDialog">test2</div>
</body>
</html>

The code above is rendered as follows: