本文介绍了SlideUp slideDown的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下javascript代码:

i have this javascript code:

var x="#wrapper"
//var xyz;
$(document).ready(function(){
    $("#about").click(function(){
    if (!(x=="#about")){
        $(x).slideUp("slow",function(){
            $("#aboutus").slideDown("slow");
            });

            x="#aboutus";
        }
    });
});
$(document).ready(function(){
    $("#home").click(function(){
        if(!(x=="#wrapper")){
        $(x).slideUp("slow", function(){
            $("#wrapper").slideDown("slow");
            });
        dd="#wrapper";
        }
    });
});

带有此菜单"

<nav>
    <div class="menu">
        <ul class="ul">
    <h6>
                <li id="home" >Home</li >
                <li id="about">About</li >
                <li >performance</li >
                <li >testimonials</li >
                <li >faqs</li >
                <li >forum</li >
                <li onclick="slideUpDown()">Contact  </li >
            </ul>
        </h6>
    </div>
</nav>

我必须使用li标记作为链接,并且当我单击"about""link"时,home div必须缓慢向上滑动,而about div应该缓慢下降.请帮忙!

I must use the the li tags as links and when I click the about "link" the home div must slide up slowly and the about div is supposed to come down slowly.please help!

先谢谢您

推荐答案

我前一段时间很喜欢这个.这很简单而且有效.

I came on this nice one a while ago. It is simple and works.

function toggleForm(x) {
        if ($('#'+x).is(":hidden")) {
            $('#'+x).slideDown(200);
        } else {
            $('#'+x).slideUp(200);
        }
}

然后称它为...

onmousedown="javascript:toggleForm('div_ID');

并且为了不更改您的URL,请在同一通话中将其添加在前面

and to not change your URL add this in front on the same call

onclick="return false"

使用此脚本,您可以使用一个脚本来调用任意数量的滑动操作.要定位的div是在呼叫中具有其ID的div.

with this, you can use one script to call as many slid operations as you want. The div to be targeted is the one that has its ID in the call.

对不起...刚刚指出,它是jQuery,但不应影响任何内容.我在其他jQuery没有使用的地方使用了它.因此似乎并没有冲突.

sorry ... Just noted that it is jQuery, but should not affect anything. I used it where other jQuery did not. So does not seem to conflict anywere.

这篇关于SlideUp slideDown的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 08:37