这篇文章主要介绍了jquery中show与hide方法用法,结合实例形式分析了jquery使用show与hide方法控制页面元素显示与隐藏的简单实现技巧,需要的朋友可以参考下
本文实例分析了jquery中show与hide方法用法。分享给大家供大家参考,具体如下:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"
"http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
*{font-size:12px;}
p{width:600px;margin:auto;}
#control{background-color:gold;padding:10px;}
</style>
<script src="../js/jquery-1.5.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#btndisplay").click(function () {
$("#message").show(3000);
});
$("#btnhide").click(function () {
$("#message").hide(3000);
});
});
</script>
</head>
<body>
<p id="control">
<input id="btndisplay" type="button" value="显示p" />
<input id="btnhide" type="button" value="隐藏p" />
</p>
<p id="message">
mouseover、mouseenter的区别:p里套p。见备注。和事件冒泡有关系。<br />
不论鼠标指针穿过被选元素或其子元素,都会触发 mouseover 事件 <br />
只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件(穿过子元素不会触发)
</p>
</body>
</html>
以上就是jquery中show与hide方法用法示例的详细内容。