Big Commerce ReferenceError& InvalidStateError

时间:2017-03-28 05:56:23

标签: jquery bigcommerce

我正在尝试调试为什么我的扩展阅读还没有在我的大型商务网站上工作。

该页面是: http://snottynoses.com.au/vaporisers/

我已将以下脚本添加到页脚:

<script>
(function($) {
$('#show').click(function(e) {
    $('#cdscontainer').toggle();
$('#show').toggle();

});
$('#hide').click(function(e) {
    $('#cdscontainer').toggle();
$('#show').toggle();
});
})( jQuery );
 </script>

以下是css:

#cdscontainer {display:none;}

页面上的文字就在这里:

<a id="show" href="#cdscontainer">Read more…</a><div id="cdscontainer">
Paste text here…
<a id="hide" href="#cdscontainer">...Hide Content</a>
</div>

我不认为脚本正在正确加载,因为它不在前端工作,但是如果我使用firebug或chrome的控制台工具添加脚本,它就可以了。

如果打开检查器工具,可以看到可能导致此问题的一些控制台错误。

eath可能会导致这些错误,我可以采取哪些措施来修复它们?

感谢您提供任何帮助/意见/建议:]

1 个答案:

答案 0 :(得分:0)

您正在尝试重新初始化jQuery两次。将代码修改为:

<script>
$(function() {

  // Bind the click event handler to both elements:
  $('#show, #hide').click(function() {
    $('#cdscontainer').toggle();
    $('#show').toggle(); // Should this be here? It will hide all of the content.
  });

});
</script>