如何使用jQuery删除外部div

6

好的,我需要翻译这个结构。

 <div class="field_with_errors">
    <input id="count" name="count" size="2" type="text" />
    <label class="message" for="count_for">Required</label>
 </div>

如何去除外部的field_with_errors和内部的消息,只保留输入标签?

如果我执行以下操作:

$("#count").closest(".field_with_errors").remove()

它会移除整个div

我可以先删除内部的.message,但不确定如何删除外部的

$("#count").closest(".field_with_errors").find('.message').remove()

任何想法?
2个回答

8

5

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接