2017-03-28 43 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>