mg游戏官方网站:JavaScript学习笔记之图片库案例分析
本文实例讲述了JavaScript图片库。分享给大家供大家参考,具体如下:
一、一个javascript 图片库实例,下面是效果图
点击顶部导航,会在本页面进行刷新图片,然后,在底部会显示文本的变化
二、下面是代码
1、gallery.html代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/showPic.js"></script>
<link rel="stylesheet" type="text/css" href="css/layout.css" rel="external nofollow" />
</head>
<body>
<h1>Snapshots</h1>
<ul>
<li>
<a href="img/a.jpg" rel="external nofollow" title="Hongse Fengye" onclick="showPic(this);return false;">红色枫叶</a>
</li>
<li>
<a href="img/b.jpg" rel="external nofollow" title="Huangse Fengye" onclick="showPic(this); return false;">黄色枫叶</a>
</li>
<li>
<a href="img/c.jpg" rel="external nofollow" title="Hongse Shu" onclick="showPic(this); return false;">红色树</a>
</li>
<li>
<a href="img/d.jpg" rel="external nofollow" title="Lanse Fengye" onclick="showPic(this);return false;">蓝色枫叶</a>
</li>
</ul>
<img src="img/3302-106.jpg" id="placeholder" alt="My Gallery"/>
<p id="description">Choose an image</p>
</body>
</html>
2、showPics.js代码
function showPic(whichpic){
var sorce=whichpic.getAttribute("href");
var placeholder=document.getElementById("placeholder");
placeholder.setAttribute("src",sorce);
var text=whichpic.getAttribute("title");
var description=document.getElementById("description");
description.firstChild.nodeValue=text;
}
3、layout.css代码
img{
width: 600px;
}
body{
font-family: helvetica,arial,serif;
color: #333;
background-color: #ccc;
margin: 1em 10%;
}
h1{
color:#333;
background-color: transparent;
}
a{
color: #c60;
background-color: transparent;
font-weight: bold;
text-decoration: none;
}
ul{
padding: 0;
}
li{
float: left;
padding: 1em;
list-style: none;
}
img{
display: block;
clear: both;
}
三、几个新的DOM属性
1、childNodes
获得 body 元素的子节点集合:
document.body.childNodes;
2、nodeType
获得 body 元素的节点类型:
document.body.nodeType;
3、nodeValue
nodeValue 属性设置或返回指定节点的节点值。
4、firstChild、lastChild
firstChild 属性返回指定节点的首个子节点,以 Node 对象。
lastChild 属性返回指定节点的最后一个子节点,以 Node 对象。
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/rumen/sscc/s51492.shtml
我要分享到:
上一篇:十大博彩娱乐公司排名:java使用jacob实现word转pdf
下一篇:没有了
下一篇:没有了
必备CSS教程 Essential CSS Tutorials
- • css height
- • css line-height
- • css width
- • css min-width
- • css max-width
- • css min-height
- • css max-height
- • css border
- • css background
- • css float
- • css clear
- • css display
- • css font
- • css text-transform
- • css英文首字母大写
- • css font-variant
- • css font-weight
- • css font-style
- • css text-decoration
- • css 删除线
- • div css 虚线
- • css 注释
- • html 注释
- • css padding
- • css margin
- • css 文本
- • css font-size
- • css font-family
- • css color
- • css text-align
- • css text-indent
- • css 超链接(css a)
- • css 优化压缩
- • css id(css #)
- • css class(css .)
- • css ul li列表
- • css 圆角圆边
- • css 父级子级
- • css 指针概念
- • css cursor
- • css overflow
- • html px em pt网页单位
- • CSS important
- • CSS position
- • css z-index
- • css white-space
- • css img图片
- • css class id
- • css link与@import区别
- • css 选择器
- • css引入html
必备HTML基础教程 Essential HTML Tutorials
- • html img图片标签
- • html em标签(EM强调标签)
- • html strong加粗(strong标签)
- • html B加粗(b加粗标签)
- • strong与B加粗区别
- • h1 h2 h3 h4标签(html标题标签)
- • html A超链接锚文本
- • html注释
- • html head头部标签
- • html title标题标签
- • html meta标签
- • html link标签
- • html i斜体标签
- • html u下划线标签
- • html s删除线标签
- • html换行br标签
- • html p段落标签
- • p标签与br标签区别
- • html div标签元素
- • html span标签
- • html font标签
- • html script标签
- • html px em pt网页单位
- • html ul li列表
- • ol li列表
- • dl dt dd标签组
- • table tr td表格
- • table tr th表格
- • html form表单
- • html form input
- • html form textarea文本区域
- • html select下拉与跳转(Html select)
- • html iframe框架
- • html网页结构
- • htm html shtml区别用法
- • 网页编码charset
- • UTF-8 GBK UTF8 GB2312区别联系
- • 先写html还是先写CSS
- • 显示扩展名
- • html标签大全集合
- • html常用标签
- • 网页源代码是什么
如对文章有任何疑问请提交到DIV CSS论坛,或有任何网页制作CSS问题立即到CSS论坛发贴求解 或 直接DIVCSS5网页顶部搜索遇到DIVCSS疑问。
CSS教程文章修订日期:2019-01-09 11:34 原创:DIVCSS5
本文www.divcss5.com DIVCSS5版权所有。
最新文章NEWS
- • 虚拟主机相关知识
- • DIV CSS加载失败
- • DIV+CSS规范命名大全集合
- • CSS margin属性与用法教程
- • padding_css padding用法详解
- • DIV+CSS中让布局居中_背景图片居中_文字内容居中
- • html与xhtml的区别规范是什么
- • DIV+CSS与TABLE的网页优势何在?
- • 浅谈DIV+CSS设计开发的Xhtml网页对SEO优化的影响
- • 开发DIV+CSS的工具集合
CSS 特效CSS EFFECTS
- 纯DIV+CSS下拉菜单模块模板
- DIV+CSS分页_CSS翻页代码模板
- css form实例 用CSS实现表单form布局实例
- 经典DIV+CSS下拉菜单
- div+css不间断上下滚动模板
- 向上不间断滚动div+css+js模板
相关文章RELATED
- • mg游戏官方网站:JavaScript学习笔记之图片库案例分析
- • 十大博彩娱乐公司排名:java使用jacob实现word转pdf
- • 澳门新金沙线上娱乐:Unix 哲学与微服务架构
- • 辉煌国际网址:Delphi在Android下使用Java库的方法
- • 在线球赛:简易语言发音比较命令使用说明
- • 球皇网:、vue本地服务的完美解决方案无法通过外部IP访问
- • 百乐访官网:Html格式化输出JSON示例(测试界面)
- • 时时彩游戏气氛浓
- • 时时彩让你淡定赚钱
- • 时时彩是一个靠谱的游戏平台