此jquery select语句中的第二个参数是什么?

编程入门 行业动态 更新时间:2024-10-27 16:35:19
本文介绍了此jquery select语句中的第二个参数是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在此处看到了它.以下语句中的tbl是什么意思?这意味着什么?

I have seen it here. What is meant by tbl in the following statement? What does it imply?

var rows = $('tr', tbl);

推荐答案

上面的tbl是另一个dom元素.这作为(可选参数)context传递:

The tbl in the above is another dom element. This is passed in as the (optional parameter) context:

jQuery( selector [, context ] )

...对于selector,在这种情况下为'tr'.

...for the selector, in this case 'tr'.

基本上就是这样:

$('tr', tbl);

说返回与元素tbl 中的选择器'tr'匹配的所有内容.

给定

<table> <tr>first</tr> <table> <table id="test"> <tr>second</tr> </table>

这将返回不同的结果:

//context is global $('tr') => first & second //restrict the context to just the second table //by finding it and passing it into the selector var tbl = $('#test'); $('tr', tbl) => just second

更多推荐

此jquery select语句中的第二个参数是什么?

本文发布于:2023-07-29 08:20:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1239023.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:第二个   语句   参数   jquery   select

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!