Jquery 如何防止通过锚点单击滚动顶部?

Jquery 如何防止通过锚点单击滚动顶部?,jquery,Jquery,我的HTML页面在下面。我已经有代码,以防止在锚点击滚动到位,但它不工作 查看上面网站的主页,在图像滑块jQuery之后,我将jQuery选项卡滑块放在上面,单击特定选项卡,然后页面自动向上滚动。这是我不想要的 请帮助我使用jQuery解决这个问题。我在所有页面中使用jQuery选项卡滑块,所有页面都有相同的问题 HTML代码 <div id="divContent"> <h3 class="home_title">YOUR TURNKEY PRIVATE

我的HTML页面在下面。我已经有代码,以防止在锚点击滚动到位,但它不工作

查看上面网站的主页,在图像滑块jQuery之后,我将jQuery选项卡滑块放在上面,单击特定选项卡,然后页面自动向上滚动。这是我不想要的

请帮助我使用jQuery解决这个问题。我在所有页面中使用jQuery选项卡滑块,所有页面都有相同的问题

HTML代码

<div id="divContent">
        <h3 class="home_title">YOUR TURNKEY PRIVATE LABEL SKIN CARE MANUFACTURER</h3>
        <p class="home_title_text">
        Cosmetic Solutions is a leader in the development and manufacturing of scientifically proven, innovative personal care products. With a focus on, face, body, hair, OTC, and professional use formulations, we create some of the most cost effective, high quality and powerful products on the market. <br /><br/>
        Providing world class services to up and coming businesses, large established brands, physicians, estheticians and other skin care professionals; we specialize in research & development, custom formulization, graphic design, manufacturing, packaging and delivery. <br /><br/>
        Take advantage of our unrivaled and high quality Private Label and Contract OEM Manufacturing. Our state of the art facilities are perfectly equipped for the creation of any number of new or revised product lines. A one stop organization based out of South Florida, with over 20 years experience; we facilitate all aspects involved in the creation and manufacturing process.
        </p>
        <div id="divTabSlider">
            <ul id="tabs">
                <li><a href="#" onClick="return false;" name="#tab1">Your Brand</a></li>
                <li><a href="#" onClick="return false;" name="#tab2">Formulations</a></li>
                <li><a href="#" onClick="return false;" name="#tab3">Packaging + Decoration</a></li>
                <li><a href="#" onClick="return false;" name="#tab4">Research + Development</a></li>
                <li><a href="#" onClick="return false;" name="#tab5">Manufacturing</a></li>
            </ul>

            <div id="content">
                <div id="tab1">
                    <table width="100%" cellpadding="2" cellspacing="2">
                        <tr>
                            <td width="70%" align="left">
                                Gladios manufactures cosmetics for third parties across the world with a clear misson to market them to international companies and distributors...
                                <br/><br/><br/><br/><br/><br/><br/><br/>
                                <a href="private-label.html#tab1" class="create_column"></a>
                            </td>
                            <td align="right">
                                <img src="images/symbol_YOURBRAND.png" width="226px" height="226px" />
                            </td>
                        </tr>
                    </table>
                </div>
                <div id="tab2">                     
                    <table width="100%" cellpadding="2" cellspacing="2">
                        <tr>
                            <td width="70%" align="left">
                                Gladios has the solutions for all your custom formulation needs. With our complete in-house applications laboratory, we can customize your product for a variety of applications...
                                <br/><br/><br/><br/><br/><br/><br/><br/>
                                <a href="private-label.html#tab2" class="create_column"></a>
                            </td>
                            <td align="right">
                                <img src="images/formulation.png" width="226px" height="226px" />
                            </td>
                        </tr>
                    </table>
                </div>
                <div id="tab3">                     
                    <table width="100%" cellpadding="2" cellspacing="2">
                        <tr>
                            <td width="70%" align="left">
                                Our Clients have an abundance of options from packaging components to choose from, all aesthetically pleasing and constructed from the highest qu...
                                <br/><br/><br/><br/><br/><br/><br/><br/>
                                <a href="private-label.html#tab3" class="create_column"></a>
                            </td>
                            <td align="right">
                                <img src="images/Pack-and-decoration.png" width="226px" height="226px" />
                            </td>
                        </tr>
                    </table>
                </div>
                <div id="tab4">                     
                    <table width="100%" cellpadding="2" cellspacing="2">
                        <tr>
                            <td width="70%" align="left">
                                As an ecological cosmetics laboratory we guarantee that our ecological cosmetics are formulated using ingredients grown with biological methods a...
                                <br/><br/><br/><br/><br/><br/><br/><br/>
                                <a href="manufacturing.html#tab1" class="create_column"></a>
                            </td>
                            <td align="right">
                                <img src="images/development.png" width="226px" height="226px" />
                            </td>
                        </tr>
                    </table>
                </div>
                <div id="tab5">                     
                    <table width="100%" cellpadding="2" cellspacing="2">
                        <tr>
                            <td width="70%" align="left">
                                Our manufacturing facility enables us to meet the special demands for our clients within the reasonable deadlines and deliver cost effective qual...
                                <br/><br/><br/><br/><br/><br/><br/><br/>
                                <a href="manufacturing.html#tab2" class="create_column"></a>
                            </td>
                            <td align="right">
                                <img src="images/manufacturing.png" width="226px" height="226px" />
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <script>
                function resetTabs(){
                    $("#content > div").hide(); //Hide all content
                    $("#tabs a").attr("id",""); //Reset id's      
                }

                var myUrl = window.location.href; //get URL
                var myUrlTab = myUrl.substring(myUrl.indexOf("#")); // For localhost/tabs.html#tab2, myUrlTab = #tab2     
                var myUrlTabName = myUrlTab.substring(0,4); // For the above example, myUrlTabName = #tab

                (function(){
                    $("#content > div").hide(); // Initially hide all content
                    $("#tabs li:first a").attr("id","current"); // Activate first tab
                    $("#content > div:first").fadeIn(); // Show first tab content

                    $("#tabs a").on("click",function(e) {
                        e.preventDefault();
                        if ($(this).attr("id") == "current"){ //detection for current tab
                         return       
                        }
                        else{             
                        resetTabs();
                        $(this).attr("id","current"); // Activate this
                        $($(this).attr('name')).fadeIn(); // Show content for current tab
                        }
                    });

                    for (i = 1; i <= $("#tabs li").length; i++) {
                      if (myUrlTab == myUrlTabName + i) {
                          resetTabs();
                          $("a[name='"+myUrlTab+"']").attr("id","current"); // Activate url tab
                          $(myUrlTab).fadeIn(); // Show url tab content        
                      }
                    }
                })()
            </script>
        </div>
    </div>

您的交钥匙自有品牌护肤品制造商

化妆品解决方案是经科学验证的创新个人护理产品开发和制造领域的领导者。我们专注于面部、身体、头发、OTC和专业使用配方,创造了市场上最具成本效益、高品质和强大的产品

为新兴企业、大型知名品牌、医生、美容师和其他皮肤护理专业人士提供世界一流的服务;我们专注于研发、定制配方、平面设计、制造、包装和交付

利用我们无与伦比的高质量自有品牌和代工制造。我们最先进的设施配备完善,可用于创建任何数量的新产品线或修订产品线。一站式组织,总部位于南佛罗里达州,拥有超过20年的经验;我们促进创作和制造过程中涉及的各个方面。

Gladios为世界各地的第三方生产化妆品,并明确向国际公司和经销商销售化妆品。。。










Gladios拥有满足您所有定制配方需求的解决方案。有了我们完整的内部应用实验室,我们可以为各种应用定制您的产品。。。










我们的客户有丰富的选择,从包装组件可供选择,所有美观和建造从最高的质量。。。










作为一个生态化妆品实验室,我们保证我们的生态化妆品配方使用的成分生长与生物方法和。。。










我们的生产设施使我们能够在合理的期限内满足客户的特殊需求,并提供经济高效的质量保证。。。










函数resetTabs(){ $(“#content>div”).hide();//隐藏所有内容 $(“#制表符a”).attr(“id”,”);//重置id的 } var myUrl=window.location.href//获取URL var myUrlTab=myUrl.substring(myUrl.indexOf(“#”);//对于localhost/tabs.html#tab2,myUrlTab=#tab2 var myUrlTab name=myUrlTab.substring(0,4);//对于上面的示例,myUrlTabName=#tab (功能(){ $(“#content>div”).hide();//最初隐藏所有内容 $(“#tabs li:first a”).attr(“id”,“current”);//激活第一个选项卡 $(“#content>div:first”).fadeIn();//显示第一个选项卡内容 $(“#选项卡a”)。在(“单击”,功能(e){ e、 预防默认值(); if($(this).attr(“id”)==“current”){//当前选项卡的检测 返回 } 否则{ resetTabs(); $(this.attr(“id”,“current”);//激活此 $($(this.attr('name')).fadeIn();//显示内容
<a href="#.">link</a>
<script>
            $("#tabs a").on("click",function( event ) {
                event.preventDefault();
            });
            </script>