JavaScript Tutorial/jQuery/not
Версия от 18:52, 25 мая 2010; (обсуждение)
Not class
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("p").not(".green").css("border-color", "red");
});
</script>
<style>
p { width:60px; height:60px; margin:10px; float:left;
background:yellow; border:2px solid white; }
</style>
</head>
<body>
<body>
<p>asdf</p>
<p id="blue">asdf</p>
<p class="green">asdf</p>
<p class="gray">asdf</p>
</body>
</html>
not(expr) removes elements matching the specified expression
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").not(".green").css("color", "red");
});
</script>
</head>
<body>
<body>
<div id="results">asdf</div>
</body>
</html>
Not ID
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("p").not("#blue").css("border-color", "red");
});
</script>
<style>
p { width:60px; height:60px; margin:10px; float:left;
background:yellow; border:2px solid white; }
</style>
</head>
<body>
<body>
<p>asdf</p>
<p id="blue">asdf</p>
<p class="green">asdf</p>
<p class="gray">asdf</p>
</body>
</html>