我有一个 6 x 8 网格,基本上是同名“tselect”下的单选按钮。当页面加载时,我希望他们所有人都运行一个类似于这个的命令
$(this).closest('div').addClass('highlight', 300);
基本上通过在顶部添加一个新的 div 类来更改最近 div 的背景颜色。我尝试做一个 for 循环来遍历所有这些,但是 jquery 命令没有执行。有任何想法吗?
编辑:添加代码...
<div id="sch_cal">
<div id="sch_cal_column">
<div id="sch_cal_row">
<div id="sch_cal_time"><p class="ctime">8:00am</p></div>
<div style="height: 100%"><input class="ctime" type="radio" name="tselect"/></div>
</div>
<div id="sch_cal_row">
<div id="sch_cal_time"><p class="ctime">8:20am</p></div>
<div style="height: 100%"><input class="ctime" type="radio" name="tselect"/></div>
</div>
<div id="sch_cal_row">
<div id="sch_cal_time"><p class="ctime">8:40am</p></div>
<div style="height: 100%"><input class="ctime" type="radio" name="tselect"/></div>
</div>
<div id="sch_cal_row">
<div id="sch_cal_time"><p class="ctime">9:00am</p></div>
<div style="height: 100%"><input class="ctime" type="radio" name="tselect"/></div>
</div>
<div id="sch_cal_row">
<div id="sch_cal_time"><p class="ctime">9:20am</p></div>
<div style="height: 100%"><input class="ctime" type="radio" name="tselect"/></div>
</div>
<div id="sch_cal_row">
<div id="sch_cal_time"><p class="ctime">9:40am</p></div>
<div style="height: 100%"><input class="ctime" type="radio" name="tselect"/></div>
</div>
<div id="sch_cal_row">
<div id="sch_cal_time"><p class="ctime">10:00am</p></div>
<div style="height: 100%"><input class="ctime" type="radio" name="tselect"/></div>
</div>
<div id="sch_cal_row">
<div id="sch_cal_time"><p class="ctime">10:20am</p></div>
<div style="height: 100%"><input class="ctime" type="radio" name="tselect"/></div>
</div>
</div>