Home  >  Article  >  Web Front-end  >  Introduction to the basics of jQuery:not() selector

Introduction to the basics of jQuery:not() selector

巴扎黑
巴扎黑Original
2017-06-22 17:56:281690browse

Definition and usage

:not() selector selects all elements except the specified element.

The most common usage: used with other selectors to select all elements in the specified combination except the specified element (such as the example above).

Syntax

$(":not(selector)")

Parameters                   Description

selector           required. Specifies elements that are not selected.

This parameter accepts any type of selector.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>菜鸟教程(runoob.com)</title> 
<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("p:not(.intro)").css("background-color","yellow");
});
</script>
</head>
<body>
<h1>欢迎来到我的主页</h1>
<p class="intro">PHP中文网</p>
<p>学的不仅是技术,更是梦想!</p>
<p>学的不仅是技术,更是梦想!</p>
<p>你最喜欢的网站:</p>
<ul id="choose">
<li>Google</li>
<li>Taobao</li>
<li>PHP中文网</li>
</ul>
</body>
</html>

The above is the detailed content of Introduction to the basics of jQuery:not() selector. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn