【发布时间】:2017-07-12 13:34:49
【问题描述】:
这个小函数在页面加载时设置一些 div 隐藏,然后在单击箭头图标时显示或隐藏它们。
这在 Chrome 中运行良好,但在 FF 和 IE 中,页面加载时所有内容都可见,单击图标无任何作用。
我是 jQuery 新手,已经阅读了一些其他问题,但看不到解决方案。
$(document).ready(function() {
$(".each-panel").hide();
$(".additional_comments").hide();
$(".summaryArrowUp").hide();
$(".summaryArrowRight").click(function(){
$(".each-panel").slideDown("slow");
$(".additional_comments").slideDown("slow");
$(".summaryArrowRight").hide();
$(".summaryArrowUp").show();
});
$(".summaryArrowUp").click(function(){
$(".each-panel").slideUp("slow");
$(".additional_comments").slideUp("slow");
$(".summaryArrowRight").show();
$(".summaryArrowUp").hide();
});
这里是 HTML:
<div id="capSummaryContainer" class="infoBoxLine">
<h3 class="buildSummary">Build Summary
<span><i class="fa fa-chevron-right summaryArrowRight" aria-hidden="true"></i>
<i class="fa fa-chevron-up summaryArrowUp" aria-hidden="true"></i>
</span>
</h3>
<div class="each-panel hidden">
<div class="insider" id="capSummaryContainer_custom"></div>
</div>
<!-- Front panel contents -->
<div class="each-panel">
<h4 class="heading">Front Panel
<span>
<i class="fa fa-eye" aria-hidden="true" onclick="selectTab(2);"></i>
<i class="fa fa-trash" aria-hidden="true" onclick="skiptomylootDelete(2, 'Are you sure you want to remove all customization from the front of the cap?');"></i>
</span>
</h4>
<div class="insider" id="capSummaryContainer_front">
<div class="designname"></div>
</div>
</div>
<!-- Left panel contents -->
<div class="each-panel">
<h4 class="heading">Left Panel
<span>
<i class="fa fa-eye" aria-hidden="true" onclick="selectTab(3);"></i>
<i class="fa fa-trash" aria-hidden="true" onclick="skiptomylootDelete(3, 'Are you sure you want to remove all customization from the left side of the cap?');"></i>
</span>
</h4>
<div class="insider" id="capSummaryContainer_left">
<div class="designname"></div>
</div>
</div>
【问题讨论】:
-
控制台有错误吗?顺便说一句,你的 JavaScript 有语法错误。
-
没有足够的代码来重现问题。所有发布的看起来都在工作...但是
selectTab()和skiptomylootDelete()未定义...因为没有发布。 -
下面的答案只在 ready 函数中添加了一个右括号
});和一个右括号</div>...当我告诉重现没有问题时我也做了... -
谢谢 - 我实际上能够通过最初使用 CSS 而不是 jQuery 隐藏我的 div 并将代码嵌套在另一个具有事件连接的函数中来使其在所有浏览器中运行良好 - 我认为document.ready 可能在不止一个地方,它让浏览器感到困惑。这是一个非常大且难以导航的项目的一部分,我没有意识到还有另一个 document.ready 函数。
标签: jquery html internet-explorer firefox click