<td class="rsvp_role "> <input value="0" name="rsvp_role186[]" type="hidden"><span class="squaredFour" style="marign-top:-9px;" id="spnrsvp_Tank186"><input id="rsvp_Tank186" name="rsvp_role186[]" value="21" class="rsvpclass_186" style="margin-right:-10px;" type="checkbox"><label style=" margin-top:-3px;" for="rsvp_Tank186"></label></span></td>
<td class="rsvp_role "> <input value="0" name="rsvp_role186[]" type="hidden"><span class="squaredFour" style="marign-top:-9px;" id="spnrsvp_Healer186"><input id="rsvp_Healer186" name="rsvp_role186[]" value="22" class="rsvpclass_186" style="margin-right:-10px;" type="checkbox"><label style=" margin-top:-3px;" for="rsvp_Healer186"></label></span></td>
<td class="rsvp_role "> <input value="0" name="rsvp_role186[]" type="hidden"><span class="squaredFour" style="marign-top:-9px;" id="spnrsvp_Dps186"><input id="rsvp_Dps186" name="rsvp_role186[]" value="23" class="rsvpclass_186" style="margin-right:-10px;" type="checkbox"><label style=" margin-top:-3px;" for="rsvp_Dps186"></label></span></td>
<td class="rsvp_role "> <input value="0" name="rsvp_role186[]" type="hidden"><span class="squaredFour" style="marign-top:-9px;" id="spnrsvp_Support186"><input id="rsvp_Support186" name="rsvp_role186[]" value="25" class="rsvpclass_186" style="margin-right:-10px;" type="checkbox"><label style=" margin-top:-3px;" for="rsvp_Support186"></label></span></td>
<td class="rsvp_role "> <input value="0" name="rsvp_role186[]" type="hidden"><span class="squaredFour" style="marign-top:-9px;" id="spnrsvp_N/A186"><input id="rsvp_N/A186" name="rsvp_role186[]" value="26" class="rsvpclass_186" style="margin-right:-10px;" type="checkbox"><label style=" margin-top:-3px;" for="rsvp_N/A186"></label></span></td>
以上是我的views.php的html源码。在上面,是动态创建的。我想在第三类中添加一些 css,其余的我不想改变。因为除了第三类之外的所有内容都正确对齐,而第三类没有正确对齐。如果我应用它适用于所有人并影响其他类的通用样式。
是否可以在 a 或 or 中检测到第 3 类,以便我可以将某些样式应用于该特定类。
最佳答案
尝试使用 .eq(index)
,
$('td.rsvp_role').eq(2) //since .eq() is having zero based index, 2 points 3
根据您必须使用的新请求,
$('tr td.rsvp_role:nth-child(3)')
关于javascript - 如何检测类(class)位置并应用风格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22470624/