当元素的构造未知时,删除Html元素

Remove Html Element when the construction of element is unknown

本文关键字:元素 删除 Html 未知      更新时间:2024-01-26

我有img html元素,我想在特定条件下隐藏或删除它,但元素的构造是未知的,每当我试图控制台它时,它都会给出null。元素是使用extJs3.4构造的。

Jquery:

$('#FACILITY_ID_field__div').find('img.x-form-trigger').remove();

HTML:

<div id="FACILITY_ID_field__div">
   <input type="hidden" id="id32" name="FACILITY_ID" value="5776" placeholder="Facility ID, name, or location" class="fieldsXtraLength">
   <div class="lov-sleek" id="ext-gen109">
      <div class="x-form-field-wrap x-form-field-trigger-wrap x-trigger-wrap-focus" id="ext-gen110" style="width: 450px;"><input type="text" id="idlov32" name="FACILITY_ID_lov" class="x-superboxselect-input x-form-text x-form-field x-form-focus" value="" placeholder="Facility ID, name, or location" style="width: 425px;"><img src="/ext/resources/images/default/s.gif" class="x-form-trigger x-form-arrow-trigger " id="ext-gen111"></div>
   </div>
</div>

首先您必须查看元素是否可见,然后您必须执行此操作---

if $('#FACILITY_ID_field__div').find("img[class='x-form-trigger']").is(":visible"){
   $('#FACILITY_ID_field__div').find("img[class='x-form-trigger']").remove();      
}

它认为它将帮助您