我的表设计如下:
<table>
<thead>
<tr><th class='fc-id1 ui-widget-header'>09:00</th></tr>
<tr><th class='fc-id2 ui-widget-header'>09:30</th></tr>
<tr><th class='fc-id3 ui-widget-header'>10:00</th></tr>
</thead>
<tbody>
<tr id='res1'><td class='fc-id4 ui-widget-content fc-resource1 '><div class=day-content'></div></td></tr>
<tr id='res2'><td class='fc-id5 ui-widget-content fc-resource2 '><div class=day-content'></div></td></tr>
<tr id='res3'><td class='fc-id6 ui-widget-content fc-resource3 '><div class=day-content'></div></td></tr>
</tbody>
</table>
现在在页面加载上,我想将 th 的值与当前时间进行比较。我有唯一的 resourceid 可以与 tr id 和 td 类进行比较。
我正在尝试使用此代码。但它不工作。它给出空值。
var td = $('.fc-resource'+ id); // this id will be the unique id coming from ajax.
var th = td.closest('tbody').prev('thead').find('> tr > th:eq(' + td.index() + ')').html();
alert(th);
谁能帮帮我?