0
我試圖顯示/隱藏某些內容,當我點擊一個tr時,它以某種方式無法正常工作。這是簡化的代碼:
HTML:
<table>
<tr onclick="showDetails()">
<td>Some text
<br> <span class="hiddenContent">Some hidden content</span>
</td>
<td>Some More Text
<br> <span class="hiddenContent">Some hidden content</span>
</td>
</tr>
<tr onclick="showDetails()">
<td>Some text
<br> <span class="hiddenContent">Some hidden content</span>
</td>
<td>Some More Text
<br> <span class="hiddenContent">Some hidden content</span>
</td>
</tr>
</table>
的JavaScript:
function showDetails() {
$(".hiddenContent").hide();
$(this).find(".hiddenContent").show();
}
通過「有點不工作」你的意思是'。 hiddenContent'應該顯示,但它不是? – 2015-03-18 21:07:21
這個''不指向被點擊的元素。 – undefined 2015-03-18 21:07:25
是KJ Price,這正是我的意思。 012huVohuman,它指的是什麼? – Smiley 2015-03-18 21:09:14