此jquery select语句中的第二个参数是什么? [英] What is the second argument in this jquery select statement?
本文介绍了此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语句中的第二个参数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文