.hide([duration][,complete])——目标元素的隐藏。

.show([duration][,complete])——目标元素的显示;

.toggle([duration][,complete])——当目标元素隐藏时则显示。否则隐藏。

注:可选參数[duration]为方法运行的时间区间;[,complete]为回调函数。

<!DOCTYPE html>
<html lang="zh_CN">
<head>
<meta charset="UTF-8">
<title>显示与隐藏</title>
<script src="js/jquery-2.1.3.min.js"></script>
<script src="js/my.js"></script>
<style>
div{
background: #005599;
width: 100px;
height: 100px;
margin: 5px;
float: left;
}
</style>
</head>
<body>
<img src="images/g.jpg"/>
<button id="btn1">隐藏</button>
<button id="btn2">显示</button>
<button id="btn3">隐藏/显示</button> </body>
</html>

my.js代码部分:

/*显示与隐藏*/
$(document).ready(function(){
//隐藏
$('#btn1').click(function(){
//$('img').hide();
$('img').hide(1000);
});
//显示
$('#btn2').click(function(){
//$('img').show();
$('img').show(1000);
});
//切换显示与隐藏
$('#btn3').click(function(){
//$('img').toggle();
$('img').toggle(1000);
});
//利用hide()制作一个效果
for(var i=0;i<5;i++){
$("<div>").appendTo(document.body);
}
$('div').click(function(){
$(this).hide(2000,function(){
$(this).remove();
})
})
})

最新文章

  1. jquery 获取设置值、添加元素详解
  2. DevStack安装时报“download of get-pip.py failed”
  3. 投行风云:FO的酸甜苦辣【转】
  4. Nginx与X-Sendfile
  5. HTML5 Canvas 的事件处理---转
  6. 使用CSS3 Media Queries实现网页自适应(转)
  7. ES6字符串扩展
  8. 使用CXF开发JAX-WS类型的WebService
  9. [HNOI 2001]产品加工
  10. HibernateTemplate 查询原生sql及ljava.lang.object cannot be cast to
  11. 一起学HBase——简单介绍HBase各种组件
  12. ---Ubuntu 16.04 server 不能关机问题解决
  13. Innodb引擎中Count(*)
  14. ALV 动态行列
  15. bzoj1009 KMP+矩阵dp
  16. vue前端知识点整理
  17. 制作Visual Studio 2019 (VS 2019) 离线安装包
  18. JDK、JRE和JAR区别(转载)
  19. Java Tools &amp;Tools APIs
  20. 使用apt install和使用apt-get install的区别是什么

热门文章

  1. 线程同步工具之CountDownLatch
  2. /usr/local/lib/libz.a: could not read symbols: Bad value(64 位 Linux)
  3. UITableView中的dequeueReusableCellWithIdentifier的方法
  4. SQL Reverse函数
  5. 6、Python模块
  6. How to initialize th rasp berry PI
  7. python项目导出所需要的依赖库
  8. node - 关于package.json
  9. 标准库Stack的一种实现
  10. cordova与ios native code交互的原理