:not( )に関して – jquery
環境
- :not( )
- js
- Javascript
- html
- html5
- HTML
- HTML5
- jquery
- jQuery
概要
指定したセレクタ「以外」の要素を選択
指定したセレクタのみ除外
実装
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("button").click(function(){
$("div:not(.sample)").css("background-color","red");
});
});
</script>
<style type="text/css">
<!--
div{
color:fff;
width:300px;
margin:15px;
padding:5px;
background-color:#09C;
}
-->
</style>
</head>
<body>
<div class="tes">class属性がsampleのdiv</div>
<div>div</div>
<div class="sample">class属性がtestのdiv</div>
<div>div</div>
<button>CLICK</button>
</body>
</html>