我正在尝试更改剧透,但我对 javascript 代码有疑问
这是剧透: http://nathan3000.altervista.org/Jdownloader%20Spoiler/zzzz.html
当我点击图片“MAC”时,扰流板打开。当我再次点击 MAC 时,扰流板关闭。但是当我在文本之间单击时,扰流板再次关闭。 我不希望扰流板在我单击文本中间时关闭 但仅当我单击图像“MAC”时才关闭。
<
如何更改选择器,使其仅在我单击图像时显示/隐藏?
我仍在.OS 容器内单击
不明白为什么在线版没有表格边框,而本地版可以看到表格边框。
剧透的javascript代码是这样的:
<script type="text/javascript">
$(document).ready(function(){
$(".nonjs").removeAttr( "href"); //href is needed for users without JS
$('.OS').click(function(){
if($(this).find(".details").is(":visible"))
{
$(this).find(".details").not(":hidden").hide("slow");
return true;
}
else
{
$(this).find(".details").show("slow");
return false;
}
});
});
</script>
<style type="text/css">
<!--
.details {
display: none;
clear: both;
padding: 2px;
}
.nonjs{
cursor:pointer;
}
img {
border: 0px;
}
-->
</style>
提前致谢
最佳答案
这是有效的:
$(document).ready(function(){
$(".nonjs").removeAttr( "href");
//href is needed for users without JS
$('.OS').click(function(e){
if(!$(e.target).parents('.details').length){
if($(this).find('.details').is(":visible"))
{
$(this).find('.details').not(":hidden").hide("slow");
return true;
}
else
{
$(this).find('.details').show("slow");
return false;
}
}
});
});
关于javascript - 如何更改扰流板的选择器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11778107/