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