我試圖在着陸頁上創建這種視差效果。另請參閱本教程https://www.youtube.com/watch?v=WTZpNAbz3jg(跳至21:00)jquery。console.log和.scroll偵聽器不起作用
我現在正在創建該網站的jquery一面,但我已經有一個這個網站的js文件,並創建了一個新的登陸頁面(也試圖把代碼放在我的主js文件。 ,來測試監聽器和控制檯,我有這樣的代碼。
$(window).scroll(function(){
console.log('h1')
});
而且,這裏是在我的主要的js代碼文件
$(document).ready(function(){
$("#graphics").hide();
$("#morew").hide();
//------------landing scroll---------------//
$(window).scroll(function(){
console.log('h1')
});
//------------Toggle---------------//
$("#hideshow1").click(function(){
$("#photography").slideToggle("slow");
$("#graphics").slideUp("slow");
});
$("#hideshow2").click(function(){
$("#graphics").slideToggle("slow");
$("#photography").slideUp("slow");
});
$("#hsw").click(function(){
$("#morew").slideToggle("slow")
});
$("#hsw2").click(function(){
$("#morew").slideUp("slow")
});
//------------before and after---------------//
//------------carousel---------------//
//------------before and after functions---------------//
$(".top").css("width", "50%");
$(".ba").mousemove(function(e){
// get the mouse x (horizontal) position and offset of the div
var offset = $(this).offset();
var iTopWidth = (e.pageX - offset.left);
// set width of bottomimage div
$(this).find(".top").width(iTopWidth);
});
//-----------lightbox/fancybox js---------------//
$('.fancybox-thumbs').fancybox({
prevEffect : 'none',
nextEffect : 'none',
closeBtn : false,
arrows : false,
nextClick : true,
helpers : {
thumbs : {
width : 50,
height : 50
}
}
});
});
但顯然沒有工作,也在這裏是從腳本鏈接我的html
<script type="text/javascript" src="js\jquery.js"></script>
<script type="text/javascript" src="js\script2.js"></script>
<script type="text/javascript" src="js\landing.js" defer></script>
<link rel="stylesheet" href="CSS\style2.css">
我也嘗試在關閉html標記之前放置「landing.js」腳本標記,並嘗試添加「延遲」,但沒有任何效果。如果任何人都可以提供幫助,我將非常感謝,同時我很抱歉,我剛剛開始使用java/jQuery。
基本上是:我只是想知道爲什麼滾動監聽器無法正常工作,我創建了另一個網站,只是爲了測試它,它工作正常。
您是否獲得在控制檯中的任何錯誤? –
爲什麼要將源文件與反斜槓鏈接? – towerofnix
是的,這一個「未捕獲的錯誤:Bootstrap的JavaScript需要jQuery(匿名函數)@ bootstrap.min.js:6」 除此之外,我有「GET chrome-extension:// ....」錯誤 – rinkemiku