开发者

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 trs

$("#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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜