Javascript 单击与其他jquery函数的链接后,scrollTop不工作
我有一个功能的链接,可以分解某个div并打开另一个div。我也想将scrollTop的功能添加到顶部,但它没有响应。。。我认为代码是完美的,但也许我遗漏了什么 JQUERY:Javascript 单击与其他jquery函数的链接后,scrollTop不工作,javascript,jquery,scroll,scrolltop,Javascript,Jquery,Scroll,Scrolltop,我有一个功能的链接,可以分解某个div并打开另一个div。我也想将scrollTop的功能添加到顶部,但它没有响应。。。我认为代码是完美的,但也许我遗漏了什么 JQUERY: // Effect to scroll top NOT WORKING $('.bio').click(function(){ $('html, body').animate({scrollTop : 0},800); return false; }); /*
// Effect to scroll top NOT WORKING
$('.bio').click(function(){
$('html, body').animate({scrollTop : 0},800);
return false;
});
/* Open and closing feature on the about/faq */
//When button is clicked
$('.text-btn').on('click', function(e) {
//Prevent url from changing
e.preventDefault();
//Find current popup based on data-popup attribute
var thisInfo = $('.info-' + $(this).data('info'));
//Hide all other popups
$('.info').not(thisInfo).fadeOut(0, function(){
thisInfo.fadeIn(400);
});
//Show this popup
});
HTML:
我运行时,您的代码似乎运行得很好 您是否已将jQuery封装在$document.ready中
否则,您的问题可能在页面的其他地方。您的控制台是否显示任何错误?整个文件位于$window.loadfunction下。所有其余的jQ命令都在工作。。。我试图将其更改为documentready,但仍然不起作用。在控制台我得到一个错误,但它与此无关。。。这是fontello字体的错误。我不明白为什么滚动不起作用,下面的jquery正在工作。我还尝试插入与另一个函数相同的类名,但它仍然没有滚动到顶部。有什么想法吗?对不起,不知道,因为你的代码对我有用。尝试创建一个空页面,只移动上面的部分。看看它是否有效。如果是这样的话,你可以继续看代码的其余部分,然后在其他地方寻找问题。奇怪的是,当我从chrome转换到firefox时,它居然奏效了。可能是缓存问题。。。
<section class="content-block scroll-pane">
<article class="content-post">
<div class="info info-1" id="info-1">
<p>CEPODS creates commercial & residential environments using shipping containers. Our aim is to create a community of enthusiast with each build of our unique modern designs.</p>
<p>CEPODS are seen as efficient and effective pod styled units, when compared to other typical commercial spaces such as brick & mortar, food trucks, tent rentals or temporary (pop-up) stores.</p>
<p>CEPODS modern design standards are ideal for anyone interested in operating, marketing, advertising or expanding their presence by using innovative alternative commercial space with shipping containers. The ideal CEPODS clients -are small to large businesses, start-up, pop-up, 2nd store, test retail outlet, and advertising & marketing platforms. Our client base is also expanded to residential and lodging enthusiasts. Many more all welcome.</p>
<p>CEPODS expertise is based in architecture, engineering, design/build, real estate, marketing, retail sales and small business management. Our team of professionals shares the same common passion; produce high quality modern design builds.</p>
<h1>
<a href="#" class="text-btn bio" id="info-2-link" data-info="2">Bio<i class="icon-right-open-gal"></i></a>
</h1>
</div>
<div class="info info-2" id="info-2">
<h1>Micro Spaces LLC</h1>
<p>Executive Member: <a href="#"class="pop-btn pop-link" data-popup="1">TIMOTHY DUNLAP/TIAN MAO</a></p>
<p>Executive Member: <a href="#"class="pop-btn pop-link" data-popup="2">ANDREW HAGUE II</a></p>
<p>Director of Engineering: <a href="#"class="pop-btn pop-link" data-popup="3">RICK DE LA GUARDIA</a></p>
<p>Project Architect: <a href="#"class="pop-btn pop-link" data-popup="4">IBRAHIM GREENIDGE</a></p>
<h1>
<a href="#" class="text-btn bio" id="info-1-link" data-info="1">about<i class="icon-right-open-gal"></i></a>
</h1>
</div>
</article>
</section>
$(document).ready(function () {
// Effect to scroll top NOT WORKING
$('.bio').click(function () {
$('html, body').animate({
scrollTop: 0
}, 800);
return false;
});
/* Open and closing feature on the about/faq */
//When button is clicked
$('.text-btn').on('click', function (e) {
//Prevent url from changing
e.preventDefault();
//Find current popup based on data-popup attribute
var thisInfo = $('.info-' + $(this).data('info'));
//Hide all other popups
$('.info').not(thisInfo).fadeOut(0, function () {
thisInfo.fadeIn(400);
});
//Show this popup
});
});