jQuery Selector How to - Select class not having myTable string








Question

We would like to know how to select class not having myTable string.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-compat-git.js'></script>
<script type='text/javascript'>
$(function(){<!--from   w  ww.  j a v a 2s.  c o  m-->
    $("span[class^='myTable']").not('#notThis').hide();
});
</script>
</head>
<body>
  <span id="notThis" class="myTable"> myTable 1</span>
  <span class="myTable2"> myTable 2</span>
  <span class="myTable3"> myTable 3</span>
</body>
</html>

The code above is rendered as follows: