推 mrbigmouth:$('ul.album-list').not(':has(input)').hide() 12/06 17:30
請教各位前輩,小弟html碼如下:
-----------------------------------------------------
<ul class="box36">
<li class="subitem">
<h3> 標題1 </h3>
<table>
<tbody><tr>
<td>
<ul class="album-list">
</ul>
</td>
</tr>
</tbody></table>
</li>
</ul>
<ul class="box36">
<li class="subitem">
<h3> 標題2 </h3>
<table>
<tbody><tr>
<td>
<ul class="album-list">
<li>
<input type="checkbox" value="137" name="CheckSchool">S1
</li>
<li>
<input type="checkbox" value="24" name="CheckSchool">S2
</li>
<li>
<input type="checkbox" value="34" name="CheckSchool">S2
</li>
</ul>
</td>
</tr>
</tbody></table>
</li>
</ul>
-----------------------------------------------------
避免文章過長,html碼有消減過…主要是頁面上會存在多個<ul class="box36">
而小弟想藉由Jquery判斷<ul class="box36">下是否有<input type="checkbox"....>
如果沒有的話,就把該<ul class="box36">隱藏掉
目前的寫法如下:
$('ul.album-list').find('li').each(function(){
$(this).parents('.box36').hide();
})
但此寫法只能隱藏掉有 checkbox 的<ul class="box36">,
請問如何修改,才能隱藏掉沒有checkbox 的<ul class="box36">
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.125.235.184
※ 編輯: fr730149 來自: 140.125.235.184 (12/06 12:04)
※ 編輯: fr730149 來自: 140.125.235.184 (12/06 12:05)