简体   繁体   English

切换选项卡时,jQuery SlideDown不起作用

[英]JQuery SlideDown isn't working when switched tab

I have HTML with some tabs when we hover on a tab a div slides down with details and when we hover on the second tab the first div slides up and second div slides down. 当我们将div悬停在一个选项卡上时,带有详细信息的HTML带有一些选项卡;当我们将鼠标悬停在第二个选项卡上时,第一个div会向上滑动,而第二个div会向下滑动。 everything works perfect but when i open a new tab and revisit my page the sliding isn't smooth or doesn't work. 一切正常,但是当我打开一个新选项卡并重新访问我的页面时,滑动不平滑或不起作用。

HTML Page HTML页面

<div id="navbar">
    <table id="navbar_link" class="navbar_link_index">
        <tr>
            <td id="about"><a href="TEMP">TEMP </a></td>
            <td id="services"><a href="TEMP">TEMP</a></td>
            <td id="products"><a href="TEMP">TEMP</a></td>
            <td><a href="TEMP">TEMP</a></td>
            <td><a href="TEMP">TEMP</a></td>
            <td><a href="TEMP">TEMP</a></td>
        </tr>
    </table>
</div>

<div class="nav_details" id="one"><table class="nav_details_table"><tr><td width="50%"><a href="about.html"><h3>TEMP</h3><p>TEMP<br></p></a></td width="50%"><td><h3>TEMP</h3> 
    <p>TEMP</p></td></tr></table></div>

    <div class="nav_details" id="two"><table class="nav_details_table servicetbl"><tr><td width="50%"><a href="about.html"><h3>TEMP</h3><p>TEMP<br></p></a></td width="50%"><td><h3>TEMP</h3> 
        <p>TEMP</p></td></tr></table></div>

        <div class="nav_details" id="three">
            <table class="nav_details_table servicetbl"><tr><td width="50%"><a href="about.html"><h3>TEMP</h3><p>TEMP<br></p></a></td width="50%"><td><h3>TEMP</h3> 
                <p>TEMP</p></td></tr></table>
            </div>

JQUERY JQUERY

$("#one").hover(function()     {$("#one").stop().slideDown().addClass("border_bottom_cls");$("#about").css("background","red");},function(){$("#one").stop().slideUp().removeClass("border_bottom_cls");$("#about").css("background","toggle");});
$("#two").hover(function(){$("#two").stop().slideDown().addClass("border_bottom_cls");$("#services").css("background","red");},function(){$("#two").stop().slideUp().removeClass("border_bottom_cls");$("#services").css("background","toggle");});
$("#three").hover(function(){$("#three").stop().slideDown().addClass("border_bottom_cls");$("#products").css("background","red");},function(){$("#three").stop().slideUp().removeClass("border_bottom_cls");$("#products").css("background","toggle");});
<script>  
  $(document).ready(function (){
    var t = null;
    $('#main-nav-item').hover(function(){
        var that = this;
        t = setTimeout(function(){
            $('#sub-nav-item').slideDown(200);
            t = null;
        }, 300);
    }, function(){
        if (t){
            clearTimeout(t);
            t = null;
        }
        else
            $('#sub-nav-item').slideUp(200);
    });
    });
</script>

Just focus on #main-nav-item and #sub-nav-item 只需关注#main-nav-item#sub-nav-item

Copy these codes and modify with your codes. 复制这些代码并使用您的代码进行修改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM