<ul>
<li id="list">
<table cellpadding="0" cellspacing="0" width="100%" class="grid-table08" id="table1">
<tbody>
<tr><td><img src="../../Content/Images/downarrow.gif" title="Hide Details" class="hide">
</td></tr>
<tr><td align="left" valign="top" width="15" nowrap="nowrap">
Hii good morning
</td>
<tr>
</table>
</li>
<li>
<table cellpadding="0" cellspacing="0" width="100%" class="grid-table08" id="table1">
<tbody>
<tr><td><img src="../../Content/Images/downarrow.gif" title="Hide Details" class="hide">
</td></tr>
<tr><td align="left" valign="top" width="15" nowrap="nowrap">
Hii good evening
</td>
<tr>
</table>
</li>
</ul>
當我點擊id爲隱藏圖像總共有10裏我需要隱藏特定李
我的腳本如下
<script type="text/javascript">
$(function() {
$(".hide").live("click", function() {
$(".hide").closest("li").hide("slow");
});
});
但它不工作任何人都可以幫我
爲什麼你使用'#li'(好像它是一個ID),而不是隻需通過'.closest('li')'選擇?此外,您在HTML中使用'hide'作爲ID,並將其用作JavaScript中的類(參見'.')。 – m90
HTML標籤ID必須是唯一的,您多次使用ID =「list」。嘗試修復,看看是否有幫助 – Sparky
哦,對不起,謝謝@斯帕奇,@ m90 .. –