我想要隐藏选择标记,它位于tr内,没有类,td是类

时间:2017-07-12 11:30:16

标签: jquery

在下面的tr和td中动态地来自一个函数 -

<table class="adm-detail-content-table edit-table" id="edit1_edit_table">
   <tr>
    <td class="adm-detail-content-cell-l" width="40%">&nbsp;Type:</td>
        <td class="adm-detail-content-cell-r" width="60%">
            <select name="UF_TYPE">
                <option value="">Select type</option>
                <option value="26" selected="">Complaint</option>
                <option value="27">Request</option>
                <option value="28">Query</option>
            </select>
        </td>
    </tr>
</table>

3 个答案:

答案 0 :(得分:0)

这会隐藏每个tr作为孩子的select: -

$('table tr').each(function(){
 if($(this).find('select[name="UF_MODE"]').length || $(this).find('select[name="UF_TYPE"]').length){
   $(this).hide();
 };
});

实施例: -

&#13;
&#13;
$('table tr').each(function(){
 if($(this).find('select[name="UF_MODE"]').length || $(this).find('select[name="UF_TYPE"]').length){
   $(this).hide();
 };
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="adm-detail-content-table edit-table" id="edit1_edit_table">
   <tr>
    <td class="adm-detail-content-cell-l" width="40%">&nbsp;Type:</td>
        <td class="adm-detail-content-cell-r" width="60%">
            <select name="UF_MODE">
                <option value="">Select type</option>
                <option value="26" selected="">Complaint</option>
                <option value="27">Request</option>
                <option value="28">Query</option>
            </select>
        </td>
    </tr>
    <tr>
      <td class="adm-detail-content-cell-l" width="40%">&nbsp;Type:</td>
        <td class="adm-detail-content-cell-r" width="60%">
            <select name="UF_TYPE">
                <option value="">Select type</option>
                <option value="26" selected="">Complaint</option>
                <option value="27">Request</option>
                <option value="28">Query</option>
            </select>
        </td>
    </tr>
    <tr>
      <td class="adm-detail-content-cell-l" width="40%">&nbsp;Type:</td>
        <td class="adm-detail-content-cell-r" width="60%">
            <select name="UN_TYPE">
                <option value="">Select type</option>
                <option value="26" selected="">Complaint</option>
                <option value="27">Request</option>
                <option value="28">Query</option>
            </select>
        </td>
    </tr>
</table>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

&#13;
&#13;
$(function(){
$('.adm-detail-content-cell-r select').hide();
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="adm-detail-content-table edit-table" id="edit1_edit_table">
   <tr>
    <td class="adm-detail-content-cell-l" width="40%">&nbsp;Type:</td>
        <td class="adm-detail-content-cell-r" width="60%">
            <select name="UF_TYPE">
                <option value="">Select type</option>
                <option value="26" selected="">Complaint</option>
                <option value="27">Request</option>
                <option value="28">Query</option>
            </select>
        </td>
    </tr>
</table>
&#13;
&#13;
&#13;

如果你想要隐藏完整的行,请使用它:

   $(function(){
      $('tr:first-child').hide();
   });

&#13;
&#13;
$(function(){
$('tr:first-child').hide();
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="adm-detail-content-table edit-table" id="edit1_edit_table">
   <tr>
    <td class="adm-detail-content-cell-l" width="40%">&nbsp;Type:</td>
        <td class="adm-detail-content-cell-r" width="60%">
            <select name="UF_TYPE">
                <option value="">Select type</option>
                <option value="26" selected="">Complaint</option>
                <option value="27">Request</option>
                <option value="28">Query</option>
            </select>
        </td>
    </tr>
</table>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

Jquery为您提供selectorhide()功能。您只需要使用要隐藏的jquery selector选择元素,然后应用hide()函数进行隐藏。 hide()函数将显示阻止该元素,您也可以使用jquery remove()函数将其删除。

&#13;
&#13;
$('.adm-detail-content-table tr td.adm-detail-content-cell-r select').hide();
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="adm-detail-content-table edit-table" id="edit1_edit_table">
  <tr>
    <td class="adm-detail-content-cell-l" width="40%">&nbsp;Type:</td>
    <td class="adm-detail-content-cell-r" width="60%">
      <select name="UF_TYPE">
                <option value="">Select type</option>
                <option value="26" selected="">Complaint</option>
                <option value="27">Request</option>
                <option value="28">Query</option>
            </select>
    </td>
  </tr>
</table>
&#13;
&#13;
&#13;