JQuery删除父元素 [英] JQuery Remove Parent Elements
本文介绍了JQuery删除父元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些第三方HTML,如下所示:
I have some third party HTML that looks like this:
<tr>
<td>
<asp:Label ID="lblURL" AssociatedControlID="txtURL"
runat="server" EnableViewState="false" CssClass="FieldLabel" />
</td>
<td>
<cms:CMSTextBox ID="txtURL" runat="server"
CssClass="TextBoxField" EnableViewState="false"
MaxLength="450" ProcessMacroSecurity="false" />
</td>
</tr>
我不允许更改此HTML。我想隐藏这个标签和输入标签,并想出了如何在JQuery中使用以下代码来实现:
I am not allowed to change this HTML. I want to hide this label and input tag and have figured out how to do that in JQuery with this code:
$('label[id$="lblURL"]').hide();
$('input[id$="txtURL"]').hide();
这有效地隐藏了页面中的元素。问题是父母和元素仍然存在。如何删除tr和td元素?
This effectively hides the elements from the page. Problem is that the parent and elements still remain. How can remove the tr and td elements?
推荐答案
它看起来像您的标签和输入框始终在封闭的表格行中,所以你可以隐藏整个表格行:
It looks like your label and input box are always in an enclosing table row, so you can hide the whole table row:
$('label[id$="lblURL"]').closest('tr').hide();
这篇关于JQuery删除父元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文