jQuery选择器

  1. jQuery选择器
    1. 内容选择器
    2. 选择器

jQuery选择器

内容选择器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>14-jQuery内容选择器</title>
<style>
div{
width: 50px;
height: 100px;
background: red;
margin-top: 5px;
}
</style>
<script src="js/jquery-1.12.4.js"></script>
<script>
$(function () {
// 编写jQuery相关代码
// :empty 作用:找到既没有文本内容也没有子元素的指定元素
// var $div = $("div:empty");
// console.log($div);

// :parent 作用: 找到有文本内容或有子元素的指定元素
// var $div = $("div:parent");
// console.log($div);

// :contains(text) 作用: 找到包含指定文本内容的指定元素
// var $div = $("div:contains('我是div')");
// console.log($div);

// :has(selector) 作用: 找到包含指定子元素的指定元素
var $div = $("div:has('span')");
console.log($div);
});
</script>
</head>
<body>

<div></div>
<div>我是div</div>
<div>他们我是div123</div>
<div><span></span></div>
<div><p></p></div>

</body>
</html>

选择器

*


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 2113132982@qq.com

文章标题:jQuery选择器

文章字数:264

本文作者:南邮石磊

发布时间:2020-07-14, 15:38:42

最后更新:2020-08-06, 00:34:50

原始链接:https://southpost.github.io/2020/07/14/jQuery%E9%80%89%E6%8B%A9%E5%99%A8/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录
×

喜欢就点赞,疼爱就打赏