문제

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