How to select all table rows (tr) that contained a class (jquery)
I have a 开发者_运维问答table (#tbLog) and need to select all table rows (tr) that contain a class called private.
Thanks
Simple enough:
$("#tbLog tr.private").action();
If you have sub tables (why?), then use this instead to only select the top level tr
s
$("#tbLog > tbody > tr.private").action();
Note that I've included tbody
in the selector as nearly all browsers will add this tag for you (it's part of the spec).
This how it's done:
$('#tbLog tr.private')
This way?
$("table#tbLog tr.private")
SCRIPT
$('#tbLog tr.private')
That should work...
$("#tbLog").children("tr .private")
Try this code:
$('.private')
I like closest. if private is a class of element inside row
$("table#tbLog .private").closest('tr')
$("#myTable tr.pagging").click(function () { return false; });
This is just in case you want to perform no action on tr click.
I think parent
will work best assuming you want it to contain not be .private you can do
$("#tbLog tr .private").parent("tr")
this will give you an array of tr's if there is more than one satisfying the condition hope this helps
精彩评论