<div style="width:200px; height:150px; border:1px solid red;bottom:-150px:position:fixed;right:10px;">
<button id="dd">按钮</button><button onclick="down()">关闭</button>
</div>
<script>
$('#dd').click(function(){
timer=setInterval(moveUp,100);
});
var div=document.querySelector("#dd");
var timer=null;
function moveUp(){
var aa=
document.defaultView.getComputedStyle(div,null);
var bottom=parseInt(aa.bottom);
if(bottom!=0){
bottom=bottom+10;
div.style.bottom=bottom+"px";}else{
clearInterval(timer);
timer=null;
}
function moveDown(){
var aa=
document.defaultView.getComputedStyle(div,null);
var bottom=parseInt(aa.bottom);
if(bottom!=-($('#alertM').height())){
bottom=bottom-10;
div.style.bottom=bottom+"px";}else{
clearInterval(timer);
timer=null;
}
}
function down(){ //onclick 事件函数
if(timer==null){
timer=setInterval(moveDown,100);
}
}
}</script>
为什么我弹出框每次要刷新后点击才能出来,关闭后连续点击不会弹出来,需要刷新页面在点击
你点击 关闭 按钮 不是隐藏了你的div了吗?
div在页面上看不到了,你还要怎样~~~
if(bottom!=-($('#alertM').height())){
此处有误
获取的数据是带有px字符的,例如150px,所以要通过parseInt转成int
===下面是修改过后代样例代码===