Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 大商业参考错误&;无效状态错误_Jquery_Bigcommerce - Fatal编程技术网

Jquery 大商业参考错误&;无效状态错误

Jquery 大商业参考错误&;无效状态错误,jquery,bigcommerce,Jquery,Bigcommerce,我正在试着调试为什么我的“扩展阅读更多”在我的大型商业网站上不起作用 网页为: 我已将以下脚本添加到页脚: <script> (function($) { $('#show').click(function(e) { $('#cdscontainer').toggle(); $('#show').toggle(); }); $('#hide').click(function(e) { $('#cdscontainer').toggle(); $('#show').

我正在试着调试为什么我的“扩展阅读更多”在我的大型商业网站上不起作用

网页为:

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

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

});
$('#hide').click(function(e) {
    $('#cdscontainer').toggle();
$('#show').toggle();
});
})( jQuery );
 </script>
页面上的文字位于以下内容中:

<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的控制台工具添加脚本,它会起作用

如果打开inspector工具,您可以看到可能是许多控制台错误导致了这种情况

究竟是什么导致了这些错误?我该怎么做才能修复它们

感谢您的帮助/建议:

您正在尝试两次重新初始化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>

$(函数(){
//将单击事件处理程序绑定到两个元素:
$('#显示,#隐藏')。单击(函数(){
$(“#CDS容器”).toggle();
$('#show').toggle();//应该在这里吗?它将隐藏所有内容。
});
});
<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>