2017-03-28 85 views
0

我想调试为什么我的扩展阅读更多不适用于我的大型商业网站。Big Commerce ReferenceError&InvalidStateError

的页面是: 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什么引起这些错误,可能我做什么来解决这些问题?

感谢您的帮助/咨询/建议:]

回答

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>