Banner中利用Jquery隐藏显示下方DIV块
实现方式1:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src = 'jquery-1.9.1.js'></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$('#subBannerFirst').click(function(){
$('#subConFirst').css('display','block');
$('#subConSecond').css('display','none');
$('#subConThird').css('display','none');
});
});
$(document).ready(function(){
$('#subBannerSecond').click(function(){
$('#subConFirst').css('display','none');
$('#subConSecond').css('display','block');
$('#subConThird').css('display','none');
});
});
$(document).ready(function(){
$('#subBannerThird').click(function(){
$('#subConFirst').css('display','none');
$('#subConSecond').css('display','none');
$('#subConThird').css('display','block');
});
});
</script>
<!--script src = 'libs/SuperMap_Cloud.js'></script-->
</head>
<body>
<div id='myBannerList' style ='width:100%;height:20px;'>
<div id='subBannerFirst' href='#subConFirst' style='width: 50px;height: 20px;float:left;background-color:#1e3a4f;'>第一项</div>
<div id='subBannerSecond' href='#subConSecond' style='width: 50px;height: 20px;float:left;background-color:red;'>第二项</div>
<div id='subBannerThird' href='#subConThird' style='width: 50px;height: 20px;float:left;background-color:blue;'>第三项</div>
</div>
<div id='banContent' style ='width:100%;height:150px;float:left;'>
<div id='subConFirst' style ='width:100%;height:150px;display:block;background-color:#1e3a4f;float:left;'></div>
<div id='subConSecond' style ='width:100%;height:150px;display:none;background-color:red;float:left;'></div>
<div id='subConThird' style ='width:100%;height:150px;display:none;background-color:blue;float:left;'></div>
</div>
</body>
</html>
实现方式2:
js代码:
//选择隐藏或者显示Banner下的DIV块方法
function changeConFirst() {
$('#subConFirst').css('display', 'block');
$('#subConSecond').css('display', 'none');
$('#subConThird').css('display', 'none');
} function changeConSecond() {
$('#subConFirst').css('display', 'none');
$('#subConSecond').css('display', 'block');
$('#subConThird').css('display', 'none');
} function changeConThird(){
$('#subConFirst').css('display','none');
$('#subConSecond').css('display','none');
$('#subConThird').css('display','block');
}
html代码
<div id='myBannerList' style ='width:100%;height:20px;'>
<div id='subBannerFirst' href='#subConFirst' onclick='changeConFirst()' style='width: 50px;height: 20px;float:left;cursor:pointer'>第一项</div>
<div id='subBannerSecond' href='#subConSecond' onclick='changeConSecond()' style='width: 50px;height: 20px;float:left;cursor:pointer'>第二项</div>
<div id='subBannerThird' href='#subConThird' onclick='changeConThird()' style='width: 50px;height: 20px;float:left;cursor:pointer'>第三项</div>
</div>
<div id='banContent' style ='width:100%;height:150px;float:left;'>
<div id='subConFirst' style ='width:100%;height:150px;display:block;float:left;'></div>
<div id='subConSecond' style ='width:100%;height:150px;display:none;float:left;'></div>
<div id='subConThird' style ='width:100%;height:150px;display:none;float:left;'></div>
</div> 实现方式1和2其实没区别,function的定义方式不一样而已。方式一是纯jquery,第二种是定义js的函数声明。 还有第三种实现方式:利用jquery的 show(),hiden()方法,这里不再记录。
Banner中利用Jquery隐藏显示下方DIV块的更多相关文章
- 彻底抛弃PeopleEditor,SharePoint中利用Jquery Chosen创建新的人员选择器
彻底抛弃PeopleEditor,SharePoint中利用Jquery Chosen创建新的人员选择器 基于SharePoint平台开发时,人员选择器使用频率是非常高的,但是原生的人员选择器使用太麻 ...
- C#中利用JQuery实现视频网站
C#中利用JQuery实现视频网站的缩略图采集 最近有朋友想要采集优酷的视频标题和缩略图 (哈哈, 并非商业目的). 找到我帮忙, 考虑到有我刚刚发布的SpiderStudio, 我毫不犹豫的答应 ...
- 子div块中设置margin-top时影响父div块位置的解决办法
在css中设置样式时,通常会遇到用子div块margin中设置margin-top时,父div块中就会随着子div的margin-top,也会和子div执行相同的margin-top的位置样式 解决办 ...
- 子div块中设置margin-top时影响父div块位置的解决办法及其原因
解决办法①: 若子DIV块中使用margin-top,则在父DIV块中添加:overflow:hidden; 解决办法②: 在子DIV块中用padding-top代替margin-top. 有个叫 b ...
- 解决JQuery中datatables设置隐藏显示列多次提交后台刷新数据的问题
此次项目开发过程中用到了Jquery的Datatables插件,无疑他是数据列表展示,解决MVC中同步过程中先走控制器后返回视图,查询数据过程中无法提示等待的弊端, 而且他所提供的各种方法也都有较强的 ...
- 前端(jQuery)(4)-- jQuery隐藏显示与淡入淡出、滑动、回调
1.隐藏与显示 <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...
- JQuery隐藏显示详情功能
放置两个DIV:初始DIV :在Repetr绑定设置文字隐藏(三元运算符):'<%# Eval("字段2").ToString().Length>11?Eval(&qu ...
- C#中利用JQuery实现视频网站的缩略图采集
最近有朋友想要采集优酷的视频标题和缩略图 (哈哈, 并非商业目的). 找到我帮忙, 考虑到有我刚刚发布的SpiderStudio, 我毫不犹豫的答应了. 首先在网页上视频的基本结构为: div.v - ...
- ie6中利用jquery居中
1.利用jquery居中代码 <script type="text/javascript"> $hwidth=parseInt($(window).width()); ...
随机推荐
- [转载]C#委托和事件(Delegate、Event、EventHandler、EventArgs)
原文链接:http://blog.csdn.net/zwj7612356/article/details/8272520 14.1.委托 当要把方法作为实参传送给其他方法的形参时,形参需要使用委托.委 ...
- 【JS基础】DOM操作
appendChild() //向节点添加最后一个子节点 createElement() //创建元素节点 createTextNode() //创建文本节点,字符串值
- iOS多线程之9.自定义NSOperation
本文主要讲如何自定义NSOperation,以及自定义NSOperation的一些注意事项,以下载图片为例. 新建一个类,继承于NSOperation. CustomOperation.h 代码 ...
- 初识JAVA(二)(送给Java和安卓初学者)----常见错误
博主接着上篇的来讲哦,以后的更新中,博主会出一些练习题,有兴趣的可以做做然后吧代码粘贴到下面,大家可以一起研究学习,一起进步,本篇文章主要讲的是: 一.常见错误 二.连接上篇一起的训练 无论是什么方向 ...
- Nginx 反向代理、负载均衡、页面缓存、URL重写及读写分离详解
转载:http://freeloda.blog.51cto.com/2033581/1288553 大纲 一.前言 二.环境准备 三.安装与配置Nginx 四.Nginx之反向代理 五.Nginx之负 ...
- JS导出excel 兼容ie、chrome、firefox
运用js实现将页面中的table导出为excel文件,页面显示如下: 导出的excel文件显示如下: 实现代码: <!DOCTYPE html> <html> <head ...
- ThinkPHP实现定时任务
项目服务端框架我选用的是ThinkPHP,由于策划案中有需求要定时刷新指定数据,所以在windows平台我使用微软的计划任务调用bat脚本来执行下面的命令来完成 php index.php /Home ...
- SQL拼接字段数据
查询语句: SELECT STUFF ( ( SELECT ',' + --分隔符 KeyID --查询字段 FROM #tmp --查询数据表 WITH(NOLOCK) --查询条件 FOR XML ...
- ubuntu系统安装初始化脚本
ubuntu系统安装初始化脚本 经常安装卸载ubuntu,每次系统安装完成后要安装好多软件,一个个命令输很麻烦浪费时间,一个sh文件全搞定! 1. flashplayer下载:点击这里 2. Auda ...
- Markdown简介以及常用语法
Markdown简介以及常用语法 最近发现用markdown记录东西很方便,感觉和emacs的org mode很类似,但是windows下使用emacs不是很方便.特此记录一下markdown常用的语 ...