简体   繁体   English

如何轻松关闭弹出窗口?

[英]How to close a popup with ease?

I'm still learning JavaScript and i am giving myself a few exercises. 我仍在学习JavaScript,并给自己做一些练习。 I have created a small popup like div (since not sure how to create an actual popup) and it works fine. 我已经创建了一个像div这样的小弹出窗口(因为不确定如何创建实际的弹出窗口),并且工作正常。 However, i can't figure out how to close the div slowly with transition, but it closes instantly. 但是,我不知道如何通过过渡缓慢地关闭div,但是它会立即关闭。

The code is located below: 

https://jsfiddle.net/wabb5x8e/2/ https://jsfiddle.net/wabb5x8e/2/

This is code from w3schools but this is what you want. 这是来自w3schools的代码,但这就是您想要的。 W3schools is a great site for beginners so check javascript and jquery tutorial W3schools是初学者的好网站,因此请查看javascript和jquery教程

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("p").hide(1000);
    });
});
</script>
</head>
<body>

<button>Hide</button>

<p>This is a paragraph with little content.</p>
<p>This is another small paragraph.</p>

</body>
</html>

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

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