<分区>
<分区>
我正在尝试加载 slideDown。当页面打开时,div 在 2 秒后自动 slideDown。 div 由响应图像和一个名为“z-indexed”的按钮组成。 现在我需要的是 slideUp 同一个 div。我正在使用下面的代码来做,但不适用于 slideUp。当我点击 z-indexed 按钮时没有任何反应。
我是 jquery 的初学者,我真的卡住了。请帮助我,你的努力将不胜感激,谢谢。
<html>
<head>
<title>slideDown</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#mydiv").slideUp(1).delay(2000).slideDown('slow');
$("#mybutton").click(function() {
$("#mydiv").slideUp(); // i think here's the problem
});
});
</script>
<style type="text/css">
img{
width: 100%;
height: auto;
}
</style>
</head>
<body>
<h2>here is some text , you will see an image and a button, after 2 seconds. when you click on the button the div will slideUp.</h2>
<div id="mydiv">
<button id="mybutton">z-indexed</button>
<img src="php.jpg">
</div>
</body>
</html>
最佳答案
有两个问题:
$('mybutton').click...
试试这个:
$(document).ready(function() {
$("#mydiv").slideUp(1).delay(2000).slideDown('slow');
$("#mybutton").click(function() {
$("#mydiv").slideUp(); // i think here's the problem
});
});
关于jquery - onload slideDown of a div, slideUp the div on button click,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49136099/