I'm using jquery to zebra stripe a table, and it's working fine - except that there's a radio button list that is also getting the striping applied.

My table has

<table class="stripeMe">

The query is

$('.stripeMe tr:nth-child(odd)').addClass('odd');

The problem when one of the even rows contains an asp.net radiobutton list (which is rendered as a single-row table) it also gets the highlight.

Is there any way to avoid this?

有帮助吗?

解决方案

Specify children using the child-selector(docs):

$('.stripeMe > tbody > tr:nth-child(odd)').addClass('odd');

...and be sure to explicitly include a <tbody> element in your markup if you haven't.

Currently you're using the descendant-selector(docs), which selects all <tr> elements no matter how deeply nested under .stripeMe.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top