根据表中的选中项目从选择列表中删除项目
|
我有一个表,其结构类似于以下内容:
<tbody>
<tr class=\"classRow\" bgcolor=\"#EFE5D3\" style=\"font-weight: bold; font-size: 1.1em;\">
<td width=\"35px\"><a class=\"classEditLink\" name=\"33\" href=\"#\">Edit</a></td>
<td width=\"20px\"><input type=\"checkbox\" class=\"chkDeleteClass\" name=\"deleteClasses[]\" value=\"33\" /></td>
<td>CLASS1234</td>
<td>A Sample Class</td>
</tr>
<tr class=\"classDocsRow\">
<td></td>
<td align=\"right\"><input type=\"checkbox\" class=\"chkRemoveDocs\" name=\"removeDocs[]\" value=\"38-33\" /></td>
<td width=\"245px\">Document 1</td>
<td width=\"600px\">A Sample Document</td>
</tr>
</tbody>
<tbody>
<tr class=\"classRow\" bgcolor=\"#EFE5D3\" style=\"font-weight: bold; font-size: 1.1em;\">
<td width=\"35px\"><a class=\"classEditLink\" name=\"45\" href=\"#\">Edit</a></td>
<td width=\"20px\"><input type=\"checkbox\" class=\"chkDeleteClass\" name=\"deleteClasses[]\" value=\"45\" /></td>
<td>CLASS987</td>
<td>Another Sample Class</td>
</tr>
<tr class=\"classDocsRow noDocs\">
<td colspan=\"4\">
<strong>No documents are currently associated with this class.</strong>
</td>
</tr>
</tbody>
我还有一个下拉菜单,如下所示:
<select type=\"select\" id=\"classesList\" name=\"classesList\">
<option id=\"defaultClassesListItem\" value=\"0\">Select a Class...</option>
<option value=\"33\">CLASS1234 - A Sample Class</option>
<option value=\"45\">CLASS987 - Another Sample Class</option>
</select>
如您所见,下拉列表是表中类的列表。
使用jQuery,我需要从表中选中的下拉菜单中删除所有项目。
我在网站的其他地方有一个选择器,可以在表中找到选中的项目,如下所示:
$(\'#classesTable input[name=\"deleteClasses[]\"]:checked\')
因此,我认为这是一个起点。我假设我需要做一些事情,例如获取选中项目的名称值(即类的ID),然后在下拉列表中找到该值,然后根据该值删除项目。我怎样才能做到这一点?
没有找到相关结果
已邀请:
2 个回复
浩挎
新
碉罕城爸