jQuery中hide()方法用法实例
2014-12-24 00:00
936 查看
本文实例讲述了jQuery中hide()方法用法。分享给大家供大家参考。具体分析如下:
此方法可以将匹配元素隐藏。
hide()方法的用法:
此方法如果没有对隐藏效果加以时间限定,那么匹配元素会被瞬间隐藏。例如:
以上代码可以将所有div元素瞬间隐藏。
如果方法对隐藏效果加以时间限定,那么匹配元素将会在限定的事件内以比较优雅的形式隐藏。例如:
以上代码可以将所有div元素在2000毫秒(2秒)内隐藏。
此方法也可以在隐藏完成后触发一个回调函数。例如:
实例代码:
以上代码能够在隐藏完成以后触发回调函数,于是弹出一个提示框。
希望本文所述对大家的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://www.jb51.net/" /> <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使用hide方法隐藏元素自身用法实例
- jQuery中hide()方法用法实例
- jQuery使用hide方法隐藏指定元素class样式用法实例
- jquery中post方法用法实例
- jQuery的css()方法用法实例
- jQuery中val()方法用法实例
- jQuery中removeData()方法用法实例
- jQuery中ajax的get()方法用法实例
- jQuery中height()方法用法实例
- jQuery中before()方法用法实例
- jQuery中val()方法用法实例
- jQuery中prepend()方法用法实例
- jQuery中ajax的post()方法用法实例
- jQuery中fadeOut()方法用法实例
- jQuery中remove()方法用法实例
- jquery hide(),show()方法用法详解
- jQuery中fadeOut()方法用法实例
- jQuery中height()方法用法实例
- jQuery中detach()方法用法实例
- jQuery中ajax的load()方法用法实例