【发布时间】:2016-12-17 07:33:00
【问题描述】:
如何更改行中的值以根据另一行的值更新负载?
例如,在我的表格中,我有一个名为 Room Allocation 的列和另一个名为 Action 的列。如果行值 Room Allocation 列设置为 Pending,那么我希望 Action 下该特定行的按钮为 Edit 和 取消,但如果是其他任何内容(即未挂起),则按钮应为编辑和拒绝。
我怎样才能使用 jQuery 来做这件事?下面是我的代码,我已经包含了一个小提琴here:
<table id="home_tbl">
<thead>
<tr>
<th>Module Code</th>
<th>Day</th>
<th>Start Period</th>
<th>Length</th>
<th>Room Preference</th>
<th>Room Allocation</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<!-- dummy data starts here -->
<tr>
<td>COA101</td>
<td>Tuesday</td>
<td>11:00</td>
<td>2 hours</td>
<td>B.1.11</td>
<td>Pending</td>
<td><button class="cupid-green">Edit</button>
<button class="cupid-green">Cancel</button></td>
</tr>
<tr>
<td>COA201</td>
<td>Monday</td>
<td>10:00</td>
<td>1 hours</td>
<td>J001</td>
<td>J001</td>
<td><button class="cupid-green">Edit</button>
<button class="cupid-green">Cancel</button></td>
</tr>
<!-- dummy data ends here -->
</tbody>
</table>
【问题讨论】:
-
你必须使用监听器或手动操作
-
你在使用 Jquery 吗???
标签: javascript jquery dom html-table