网页‘显示更多’按钮或链接的代码

顾陌 发布时间:2014-09-23 分类:Web 阅读:3884次 添加评论

常常在手机等网站上面看到的“查看更多”按钮JS代码:

<script type="text/javascript">
	var txtHeight=0;
	var oneHeight=500;
	$(document).ready(function(){
		debugger;
		txtHeight=$("#ems_text_info").height();
		if(txtHeight>oneHeight)
		{
			$("#ems_text_info").height(oneHeight);
		}
	});
	
	function moreclick()
	{
		var h=$("#ems_text_info").height();
		if((h+oneHeight)>=txtHeight)
		{
			$("#ems_text_info").height(txtHeight);
		}
		else
		{
			$("#ems_text_info").height(h+500);
		}
	}
</script>

按钮点击事件调用moreclick事件。

关键字词: 显示更多more

暂无留言

发表评论:

◎欢迎您的参与讨论。