div中的子菜单取消激活,防止单页滚动中的默认值。 [英] Submenu inside a div deactivates prevent default in one-page scroll.

查看:116
本文介绍了div中的子菜单取消激活,防止单页滚动中的默认值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个单页滚动ASP.NET网站。我有一个主导航菜单,向下滚动到相应的部分。 关于我们部分有一个自己的子菜单。子菜单不是单页滚动。它会在点击时显示/隐藏相应的div。我使用了这个div的更新面板。

主导航链接完美运行,直到我点击子菜单链接。之后,如果我再次点击主导航链接,防止默认将不再有效。该部分的#代码显示在地址栏中,其他部分的滑块停止工作。



我在< / body>之前使用了以下代码进行单页滚动:



 jQuery( document )。ready( function ($){
$( 。scroll).click( function (e){
e.preventDefault();
$(' html,body')。animate({scrollTop:$( this 。 hash).offset()。top - 20 }, 1000 );
返回 false ;
});
});

< br $> b $ b

如何解决这个问题?

解决方案

){


< blockquote>( 。scroll)。click( function (e){
e.preventDefault();


' < span class =code-string> html,body')。animate({scrollTop:


I am working on a single-page scroll ASP.NET website. I have a main navigation menu which scrolls down to the respective sections. The 'About Us' section has a submenu of its own. The submenu isn't a single page scroll. It shows/hides respective divs on click. I have used an update panel for this div.
The main navigation links work perfectly till i click on the submenu links. After that, if i click on the main navigation links again, the 'prevent default' no longer works. The # code of that section is shown in the address bar and the sliders in the other sections stop working.

I have used the following code for the one-page scrolling, just before the </body> :

jQuery(document).ready(function ($) {
            $(".scroll").click(function (e) {
                e.preventDefault();
                $('html,body').animate({ scrollTop: $(this.hash).offset().top - 20 }, 1000);
                return false;
            });
        });



How do I correct this problem?

解决方案

) {


(".scroll").click(function (e) { e.preventDefault();


('html,body').animate({ scrollTop:


这篇关于div中的子菜单取消激活,防止单页滚动中的默认值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆