小白教程
所有教程
关于
Search
172.71.254.32
172.71.254.32
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Sel last”的源代码
本页内容
上一节:
Sel_first
下一节:
Sel_even
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE::last}}[[Category:jquery ref selectors|8]] = jQuery :last 选择器 = [[jquery ref selectors|jQuery 选择器]] 选取最后一个 <p> 元素: <sample title="" desc="" lang="html" hererun="1"> $("p:last") </sample> <run name=""> <!DOCTYPE html> <html> <head> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p:last").css("background-color","yellow"); }); </script> </head> <body> <p>This is the first paragraph.</p> <p>This is the second paragraph.</p> <p>This is the last paragraph.</p> </body> </html> </run> == 定义和用法 == :last 选择器选取最后一个元素。 '''注意:'''这个选择器只用于选取单个元素。使用 [[sel lastchild|:last-child]] 选择器选取多个元素(每个父元素一个)。 最常见的用法:与其他选择器一起使用,选取指定组合中的最后一个元素(如上面的实例)。 '''提示:'''如需选取指定组合中的第一个元素,请使用 [[sel first|:first]] 选择器。 == 语法 == <pre> $(":last")</pre> == 尝试一下 - 实例 == [[try.php?filename=tryjquery_sel_lastchild_last|:last 和 :last-child 之间的不同]] 演示 :last 和 :last-child 选择器之间的不同。 [[jquery ref selectors|jQuery 选择器]]
返回至“
Sel last
”。
上一节:
Sel_first
下一节:
Sel_even