最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

juqery学习之三选择器可见性元素属性_jquery

来源:动视网 责编:小采 时间:2020-11-27 20:56:00
文档

juqery学习之三选择器可见性元素属性_jquery

juqery学习之三选择器可见性元素属性_jquery::hidden 匹配所有的不可见元素,input 元素的 type 属性为 hidden 的话也会被匹配到 Matches all elements that are hidden, or input elements of type hidden. 返回值 Array 示例 查找所有不可见的 tr 元素 HTML 代码
推荐度:
导读juqery学习之三选择器可见性元素属性_jquery::hidden 匹配所有的不可见元素,input 元素的 type 属性为 hidden 的话也会被匹配到 Matches all elements that are hidden, or input elements of type hidden. 返回值 Array 示例 查找所有不可见的 tr 元素 HTML 代码


:hidden

匹配所有的不可见元素,input 元素的 type 属性为 "hidden" 的话也会被匹配到
Matches all elements that are hidden, or input elements of type "hidden".

返回值

Array

示例

查找所有不可见的 tr 元素

HTML 代码:




Value 1
Value 2

jQuery 代码:

$("tr:hidden")

结果:

[ Value 1 ]

---------------------------------------------------------------------------------------

:visible

匹配所有的可见元素
Matches all elements that are visible.

返回值

Array

示例

查找所有可见的 tr 元素

HTML 代码:




Value 1
Value 2

jQuery 代码:

$("tr:visible")

结果:

[ Value 2 ]

---------------------------------------------------------------------------------------

[attribute]

匹配包含给定属性的元素
Matches elements that have the specified attribute.

返回值

Array

参数

attribute (String) : 属性名

示例

查找所有含有 id 属性的 div 元素

HTML 代码:


Hello!



jQuery 代码:

$("div[id]")

结果:

[ ]

---------------------------------------------------------------------------------------

[attribute=value]

匹配给定的属性是某个特定值的元素
Matches elements that have the specified attribute with a certain value.

返回值

Array

参数

attribute (String) : 属性名

value (String) : 属性值。引号在大多数情况下是可选的。但在遇到诸如属性值包含"]"时,用以避免冲突。

示例

查找所有 name 属性是 newsletter 的 input 元素

HTML 代码:

'

jQuery 代码:

$("input[name='newsletter']").attr("checked", true);

结果:

[ , ]

---------------------------------------------------------------------------------------

[attribute!=value]

匹配给定的属性是不包含某个特定值的元素
Matches elements that don't have the specified attribute with a certain value.

返回值

Array

参数

attribute (String) : 属性名

value (String) : 属性值。引号在大多数情况下是可选的。但在遇到诸如属性值包含"]"时,用以避免冲突。

示例

查找所有 name 属性不是 newsletter 的 input 元素

HTML 代码:

'

jQuery 代码:

$("input[name!='newsletter']").attr("checked", true);

结果:

[ ]

---------------------------------------------------------------------------------------

[attribute^=value]

匹配给定的属性是以某些值开始的元素
Matches elements that have the specified attribute and it starts with a certain value.

返回值

Array

参数

attribute (String) : 属性名

value ( String) : 属性值。引号在大多数情况下是可选的。但在遇到诸如属性值包含"]"时,用以避免冲突。

示例

查找所有 name 以 'news' 开始的 input 元素

HTML 代码:



jQuery 代码:

$("input[name^='news']")

结果:

[ , ]

---------------------------------------------------------------------------------------

[attribute$=value]

匹配给定的属性是以某些值结尾的元素
Matches elements that have the specified attribute and it ends with a certain value.

返回值

Array

参数

attribute (String) : 属性名

value (String) : 属性值。引号在大多数情况下是可选的。但在遇到诸如属性值包含"]"时,用以避免冲突。

示例

查找所有 name 以 'letter' 结尾的 input 元素

HTML 代码:



jQuery 代码:

$("input[name$='letter']")

结果:

[ , ]

---------------------------------------------------------------------------------------

[attribute*=value]

匹配给定的属性是以包含某些值的元素
Matches elements that have the specified attribute and it contains a certain value.

返回值

Array

参数

attribute (String) : 属性名

value (String) : 属性值。引号在大多数情况下是可选的。但在遇到诸如属性值包含"]"时,用以避免冲突。

示例

查找所有 name 包含 'man' 的 input 元素

HTML 代码:




jQuery 代码:

$("input[name*='man']")

结果:

[ , , ]

---------------------------------------------------------------------------------------

[selector1][selector2][selectorN]

复合属性选择器,需要同时满足多个条件时使用。
Matches elements that have the specified attribute and it contains a certain value.

返回值

Array

参数

selector1 (Selector) : 属性选择器

selector2 (Selector) : 另一个属性选择器,用以进一步缩小范围

selectorN (Selector) : 任意多个属性选择器

示例

找到所有含有 id 属性,并且它的 name 属性是以 man 结尾的

HTML 代码:




jQuery 代码:

$("input[id][name$='man']")

结果:

[ ]

文档

juqery学习之三选择器可见性元素属性_jquery

juqery学习之三选择器可见性元素属性_jquery::hidden 匹配所有的不可见元素,input 元素的 type 属性为 hidden 的话也会被匹配到 Matches all elements that are hidden, or input elements of type hidden. 返回值 Array 示例 查找所有不可见的 tr 元素 HTML 代码
推荐度:
标签: 属性 jQuery 可见性
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top