使用纯的javaScript制作右下角类似腾讯新闻弹出框效果

感觉在公司呆久了,业务逻辑写的多,js的操作都快全忘了,今天帮别人写了一个纯的javaScript效果,类似于腾讯新闻的弹出效果。

html代码:

 <body style="width:800px; height:800px">
    This is my JSP page. <br>
    <!--  <div id="jsTest01" οnmοuseοver="MouseIn()" οnmοuseοut="MouseOut()" style="height:200px;width:100px;padding:30px;">nouse in</div>-->
 	
 	<div id="jsTest02" style="width:200px;height:0px ;border-color:#cc0000;position:absolute;right:0px;bottom:0px;background-color: red">
 		<table height="200px" width="200px">
 			<tr height="20%">
 				<td>新闻头条</td>
 				<td><a οnclick="closeM()">X</a></td>
 			</tr>
 			<tr height="80%">
 				<td colspan="2">新闻内容</td>
 			</tr>
 		</table>
 	
 	</div>
  </body>
js代码,使用jquery的初始化方法:
$(document).ready(function(){  
	 move=window.setInterval(moveUp,"15"); // 每次隔一段时间调用高度自增函数,定义全局变量move<pre name="code" class="javascript">function moveUp(){
	var d=document.getElementById("jsTest02");  // 得到div
	var h=0;  // 当前的div的高度
	if((h=parseInt(d.style.height))<200){ // 如果当前的高度小于100px
		
		d.style.height=(h+4)+'px';  // 每次让高度增长两个单位
	}
	else
		window.clearInterval(move);
}

function moveDown(){
	var d=document.getElementById("jsTest02");  // 得到div
	var h=0;  // 当前的div的高度
	if((h=parseInt(d.style.height))>=0){ // 如果当前的高度大于0px
		
		d.style.height=(h-4)+'px';  // 每次让高度减小
	}
	else
		window.clearInterval(down);
}

function closeM(){
	 down=window.setInterval(moveDown,"15");  // 使用全局变量down
}
// setTimeout(function(){alert("Hello")},3000);// timeOut的用法 没个一段时间相应某个方法});

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值