I have seen it here. What is meant by tbl
in the following statement? What does it imply?
var rows = $('tr', tbl);
I have seen it here. What is meant by tbl
in the following statement? What does it imply?
var rows = $('tr', tbl);
This pattern is using jQuery context. Your query is used to find the rows within the table.
var tbl = $("table#tableId"); // this line provides the context
var rows = $("tr", tbl); // finding all rows within the context
This is equivalent to writing
var rows = tbl.find("tr")
There is good explanation on using jQuery context in this SO Question here
The
tbl
in the above is another dom element. This is passed in as the (optional parameter)context
:...for the
selector
, in this case'tr'
.source
So essentially this:
says return me everything that matches the selector
'tr'
in the element(s)tbl
.Example
So given
This returns varying results: