jquery叫你怎样对图层进行隐藏和现实 一行代码超简单
2013-03-28 19:12
260 查看
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>绑定事件</title>
<style>
*{ margin:0; padding:0;}
#containter{ margin:60px; width:300px; border:1px solid #F00}
.head{ background-color:#CCC; height:20px; padding:10px; cursor:pointer}
.content{ line-height:50px; text-indent:35px;}
</style>
<script language="javascript" type="text/javascript" src="../script/jquery-1.4.2.min.js"></script>
<script>
$(function(){
/* $("div.head").bind("mouseover",function(){
$(".content").hide("slow");
}).bind("mouseout",function(){
$(".content").show("fast");
}); */
//以上是:绑定两个事件,一个hide和一个show事件达到目的,以下方法为妙
$(".head").bind("click",function(){
$(".content").slideToggle("slow");
})
//slideToggle是将目标隐藏和显示之间切换
});
</script>
</head>
<body>
<div id="containter">
<div class="head">什么是jquery?</div>
<div class="content">jquery是继prototype之后又一个javascript库的分装,它有简洁的代码结构,有强的功能,而且兼容性非常好!功能十分强大!!!</div>
</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>绑定事件</title>
<style>
*{ margin:0; padding:0;}
#containter{ margin:60px; width:300px; border:1px solid #F00}
.head{ background-color:#CCC; height:20px; padding:10px; cursor:pointer}
.content{ line-height:50px; text-indent:35px;}
</style>
<script language="javascript" type="text/javascript" src="../script/jquery-1.4.2.min.js"></script>
<script>
$(function(){
/* $("div.head").bind("mouseover",function(){
$(".content").hide("slow");
}).bind("mouseout",function(){
$(".content").show("fast");
}); */
//以上是:绑定两个事件,一个hide和一个show事件达到目的,以下方法为妙
$(".head").bind("click",function(){
$(".content").slideToggle("slow");
})
//slideToggle是将目标隐藏和显示之间切换
});
</script>
</head>
<body>
<div id="containter">
<div class="head">什么是jquery?</div>
<div class="content">jquery是继prototype之后又一个javascript库的分装,它有简洁的代码结构,有强的功能,而且兼容性非常好!功能十分强大!!!</div>
</div>
</body>
</html>
相关文章推荐
- jQuery判断元素是否显示 是否隐藏的简单实现代码
- jQuery实现风琴菜单,超级简单,一行代码!
- jQuery判断元素是否显示 是否隐藏的简单实现代码
- 关于jQuery插件jTip的修改,代码基本上没变,只进行了简单的修改,我个人认为这样更合适!
- 利用jquery的attr方法一行代码实现的简单的图片切换效果
- 怎样使用YDB进行简单的数据操作
- 简单实现jQuery进度条轮播实例代码
- jquery 隐藏与显示tr标签示例代码
- Jquery实现简单的轮播效果(代码管用)
- 用jQuery模拟select下拉框的简单示例代码
- jQuery登陆判断简单实现代码
- jquery之超简单的div显示和隐藏特效demo(分享)
- 使 WebBrowser 更简单的新加和执行 js, 可安装 jQuery 脚本的 C# 开源代码 - IEBrowser [1]
- Jquery选择器的概念以及选择器的学习一(基本、层级、简单,另有简单动画效果代码)
- jQuery图片手风琴特效一行代码搞定
- JQUERY常用效果简单实现方法淡入淡出,隐藏等
- 基于jquery实现的定时显示与隐藏div广告的实现代码
- 通过JavaScript打开网页方式进行分享-转最简单易用的开心网、人人网、新浪微博、腾讯微博、QQ空间分享代码
- 一行jQuery代码搞定checkbox 全选和全不选
- 一行代码教你隐藏标题栏