我在iframe中加载一个表单(使用facebox)。当提交表单并重新加载iframe中的页面时,我想向父页面上的特定表行添加一个CSS类。
表格如下所示:
<table>
<tr id="row-1"><td><a href="">link to open facebox with iframe</a></td></tr>
<tr id="row-2"><td></td></tr>
<tr id="row-3"><td></td></tr>
<tr id="row-4"><td></td></tr>
</table>在iframe中提交表单后,父框架中的表格应如下所示:
<table>
<tr id="row-1" **class="highlite"**>
<td><a href="">link to open facebox with iframe</a></td>
</tr>
<tr id="row-2"><td></td></tr>
<tr id="row-3"><td></td></tr>
<tr id="row-4"><td></td></tr>
</table>社区可以帮助我正确地实现它吗?
发布于 2010-08-16 18:00:51
$("#row-1", window.parent.document).toggleClass("highlite");
$()包装器的第二个参数是要搜索的上下文。默认设置为document.
发布于 2010-08-16 18:49:08
如果有可能再次单击并加载相同的链接,您可能希望使用.addClass而不是.toggleClass。.toggleClass的默认行为是检查该元素上是否存在类,然后根据结果添加或删除它。
如果您的目的是仅突出显示当前行,则需要执行以下操作:
$("#row-1", window.parent.document).addClass("highlite")
.siblings().removeClass("highlite");https://stackoverflow.com/questions/3492115
复制相似问题