我在我的頭文件中有這個代碼,它將所有頁面滾動到特定的錨點。在jQuery中添加異常
我想爲我的主頁添加一個例外,所以代碼將無法在那裏工作。
// this code is between <head> tags in my header file.
<script
function scroll(){
$('html, body').animate({
scrollTop: $('#scroll').offset().top
}, 1000);
}
</script>
// this code is at the bottom of the page in my header file
// anchor
<a href="#scroll" id="scroll"></a>
// this code is in the header file
// called
<body onload="scroll()">
你想要添加異常是什麼意思,爲什麼你想讓你的代碼失敗? – Panther 2014-12-13 17:06:55
這樣做的一種方法是檢查你的URL是否在你的主頁上,如果是 - 禁用滾動。 – Vucko 2014-12-13 17:07:31
您使用什麼服務器端語言來創建HTML?有什麼表明該腳本目前正在主頁上運行 – twinlakes 2014-12-13 17:07:59