根据id隐藏完整字段(标签和选项)

问题描述 投票:0回答:1

我试图使用 javascript 使用 id“fe3739”隐藏以下问题(标题和选项)。当我尝试使用 id(fe3739) 隐藏时,它只隐藏选项。我知道还有一个 id“formElement64”可用于隐藏完整的问题,但我的要求是使用 id“fe3739”隐藏。

<div class="grid-layout-col">
<div class="layout-col col-sm-12 col-xs-12">
<div id="formElement64" class="field-style form-element-layout row">
<div style="text-align:left;" class="col-sm-12 col-xs-12">
<label class="elq-label " for="fe3739">How would you describe your data domain?</label>
</div>
<div class="col-sm-12 col-xs-12">
<div class="row">
<div class="col-xs-12">
<div class="field-control-wrapper">
<select class="item-select" id="fe3739" name="dropdownMenu17" style="width:100%;" data-value="">
<option value="">Please Select</option>
<option value="Fraud &amp; Risk">Fraud &amp; Risk</option>
<option value="Marketing">Marketing</option>
<option value="Product">Product</option>
<option value="Sales">Sales</option>
<option value="Other">Other</option>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>```


The below one just hides the options not the complete question including title

$("#fe3739").hide();  


                                                                                                      
javascript html jquery
1个回答
0
投票

定义“完整的问题”。 您想要隐藏您所显示的顶级

<div>
吗? 您可以从目标元素中选择最接近的匹配元素。 例如:

$('#fe3739').closest('div.grid-layout-col').hide();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<div class="grid-layout-col">
   <div class="layout-col col-sm-12 col-xs-12">
      <div id="formElement64" class="field-style form-element-layout row">
         <div style="text-align:left;" class="col-sm-12 col-xs-12">
            <label class="elq-label " for="fe3739">How would you describe your data domain?</label>
         </div>
         <div class="col-sm-12 col-xs-12">
            <div class="row">
               <div class="col-xs-12">
                  <div class="field-control-wrapper">
                     <select class="item-select" id="fe3739" name="dropdownMenu17" style="width:100%;" data-value="">
                        <option value="">Please Select</option>
                        <option value="Fraud &amp; Risk">Fraud &amp; Risk</option>
                        <option value="Marketing">Marketing</option>
                        <option value="Product">Product</option>
                        <option value="Sales">Sales</option>
                        <option value="Other">Other</option>
                     </select>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </div>
</div>

© www.soinside.com 2019 - 2024. All rights reserved.