jQuery中hide()方法用法实例
作者:bea
本文实例讲述了jQuery中hide()方法用法。分享给大家供大家参考。具体分析如下: 此方法可以将匹配元素隐藏。 hide()方法的用法: 此方法如果没有对隐藏效果加以时间限定,那么匹配元素会被瞬间隐藏。例如: 代码如下: $("div").hide() 以上代码可以将所有div元素瞬间隐藏。 如果方法对隐藏效果加以时间限定,那么匹配元素将会在限定的事件内以比较优雅的形式隐藏。例如: 代码如下: $("div").hide(2000) 以上代码可以将所有div元素在
本文实例讲述了jQuery中hide()方法用法。分享给大家供大家参考。具体分析如下:
此方法可以将匹配元素隐藏。
hide()方法的用法: 此方法如果没有对隐藏效果加以时间限定,那么匹配元素会被瞬间隐藏。例如:
代码如下:
$("div").hide()
以上代码可以将所有div元素瞬间隐藏。
如果方法对隐藏效果加以时间限定,那么匹配元素将会在限定的事件内以比较优雅的形式隐藏。例如:
代码如下:
$("div").hide(2000)
以上代码可以将所有div元素在2000毫秒(2秒)内隐藏。
此方法也可以在隐藏完成后触发一个回调函数。例如:
代码如下:
$("div").hide(2000,function(){alert("我隐藏好了")});
实例代码:
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http:///" />
<title>hide()函数-</title>
<style type="text/css">
div{
color:blue;
background-color:green;
width:100px;
height:100px;
margin-top:10px;
}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#first").click(function(){
$(".first").hide();
})
$("#second").click(function(){
$(".second").hide(2000,function(){alert("我隐藏好了")});
})
})
</script>
</head>
<body>
<div class="first"></div>
<div class="second"></div>
<button id="first">瞬间隐藏</button>
<button id="second">优雅的隐藏</button>
</body>
</html>
以上代码能够在隐藏完成以后触发回调函数,于是弹出一个提示框。
希望本文所述对大家的jQuery程序设计有所帮助。
有用 | 无用
此方法可以将匹配元素隐藏。
hide()方法的用法: 此方法如果没有对隐藏效果加以时间限定,那么匹配元素会被瞬间隐藏。例如:
代码如下:
$("div").hide()
以上代码可以将所有div元素瞬间隐藏。
如果方法对隐藏效果加以时间限定,那么匹配元素将会在限定的事件内以比较优雅的形式隐藏。例如:
代码如下:
$("div").hide(2000)
以上代码可以将所有div元素在2000毫秒(2秒)内隐藏。
此方法也可以在隐藏完成后触发一个回调函数。例如:
代码如下:
$("div").hide(2000,function(){alert("我隐藏好了")});
实例代码:
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http:///" />
<title>hide()函数-</title>
<style type="text/css">
div{
color:blue;
background-color:green;
width:100px;
height:100px;
margin-top:10px;
}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#first").click(function(){
$(".first").hide();
})
$("#second").click(function(){
$(".second").hide(2000,function(){alert("我隐藏好了")});
})
})
</script>
</head>
<body>
<div class="first"></div>
<div class="second"></div>
<button id="first">瞬间隐藏</button>
<button id="second">优雅的隐藏</button>
</body>
</html>
以上代码能够在隐藏完成以后触发回调函数,于是弹出一个提示框。
希望本文所述对大家的jQuery程序设计有所帮助。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- jQuery中append()方法用法实例
- 使用mini-define实现前端代码的模块化管理
- jQuery中html()方法用法实例
- jQuery中val()方法用法实例
- 24款热门实用的jQuery插件推荐
- js获取当前时间显示在页面上并每秒刷新
- Javascript 多物体运动的实现
- Javascript 运动中Offset的bug解决方案
- jQuery中height()方法用法实例
- jQuery中width()方法用法实例
- jQuery中animate()方法用法实例
- jQuery中fadeOut()方法用法实例
- 创建js对象和js类的方法汇总
- javascript使用prototype完成单继承
- jQuery中slideUp()方法用法分析
- node.js开机自启动脚本文件
- 使用jquery动态加载js文件的方法
- 使用javascript实现Iframe自适应高度
- 常用的jQuery前端技巧收集