javascript 如何在javascript中缓慢隐藏div

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23261899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 00:38:40  来源:igfitidea点击:

How to hide div slowly in javascript

javascriptjqueryhtmlcss

提问by Atif Azad

I have two divwhen I click button to close the div. second divmoves upward I just want to do this slowly. I try to use transition effect but cant do it any help? thanks in advance. fiddle

我有两个div当我点击按钮关闭div。第二个div向上移动我只想慢慢地做这个。我尝试使用过渡效果但无济于事?提前致谢。 小提琴

回答by Roman

http://jsfiddle.net/ssZXA/185/

http://jsfiddle.net/ssZXA/185/

read the documentation about .hide()the first argument is "duration"

阅读有关.hide()第一个参数的文档是“持续时间”

You can use $("#notice").hide('slow');

您可以使用 $("#notice").hide('slow');

回答by Somnath Kharat

use fadeOut

利用 fadeOut

$( "#closebutton" ).click(function(event)
 {
    $("#notice").fadeOut('slow');  //OR fadeOut('10000') time is in milliseconds
 }); 

Jsfiddle

提琴手

回答by D Mishra

Use

利用

  $("#notice").slideToggle();

or

或者

 $("#notice").fadeOut();

In Place of

代替

 $("#notice").hide();

回答by Raja Danish

Plz try this:

请试试这个:

$("#notice").hide("slow");

Thanks.

谢谢。

回答by Siva Charan

Just apply slowon hidefunction and I customized your code as follows:

只是适用slowhide功能和定制我的代码如下:

$("#closebutton").button({
    icons: {
        primary: "ui-icon-close"
    },
    text: false
}).click(function(event) {
    $("#notice").hide("slow");
});

Refer LIVE DEMO

参考现场演示

回答by Jayesh Goyani

Try with this.

试试这个。

<body>
  <div id="myDiv" style="width:200px;height:150px;background-color:red;">
  This is the div that will fade out, slide up, then be removed from the DOM.
  </div>
  <input id="myButton" type="button" value="Fade" />
</body>

$(function() {
     $("#myButton").click(function() {
         $("#myDiv").fadeTo("slow", 0.00, function(){
             $(this).slideUp("slow", function() {
                 $(this).remove();
             });
         });

     });
});

Demo

演示

回答by Tuhin

    $("#notice").hide('fade','slow');

DEMO

演示

or

或者

 $("#notice").hide('fade',5000);

5000- indicates it will take 5seconds to hide. you can give any value.

5000- 表示隐藏需要 5 秒。你可以给出任何值。

Syntax: $("selector").hide('type',time);

语法: $("selector").hide('type',time);

回答by Amit Joki

Just do this:

只需这样做:

$("#notice").hide('fade');

or

或者

$("#notice").hide('slideUp');

instead of $("#notice").hide();

代替 $("#notice").hide();

Demo

演示

回答by test

$(function(){

    $(this).html('&laquo;'); 

    $('.slider-arrow').click(function(){    

        var x = $(".slider-arrow").offset();
        if (x.left == "308") 
        {     
            $( ".slider-arrow, .panel").animate({left: "-=300"}, 700);
        }
        else
        {
            $( ".slider-arrow, .panel").animate({left: "+=300"}, 700);    
        }
    });    
});