您的位置:首页 > Web前端 > JQuery

jQuery练习--隐藏和显示效果

2014-07-14 21:13 357 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>click.html</title>
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="this is my page">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
		<script type="text/javascript">
			$( function() {
				$("#hide").click( function() {
					//$("#content").hide();	
					$("#content").hide(1000); //规定隐藏的速度
				});
		
				$("#show").click( function() {
					//$("#content").show();
					$("#content").show(1000, test);
				});
			});

			/*
				$(selector).hide(speed,callback);
				$(selector).show(speed,callback);
				可选的 speed 参数规定隐藏/显示的速度,可以取以下值:"slow"、"fast" 或毫秒。
				可选的 callback 参数是隐藏或显示完成后所执行的函数名称。
			 */
			function test() {
				alert("hello,world");
			}
		</script>

	</head>

	<body>
		<p id="content">
			如果点击隐藏按钮,会消失。再次点击显示按钮,会显示。
		</p>

		<button id="hide">隐藏</button>
		<button id="show">显示</button>

	</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: