今天终于搞明白之前为什么不能用外部的js文件了src后面接的直接就是外部的地址,不需要加上什么scripts/****之类的
还有引用js的时候js的文件是不需要再加上什么<script>
的标签的
辣鸡书籍,毁我青春
html部分
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Image</title>
<!--
<script>
function showPic(whichpic){
var source = whichpic.getAttribute("href");
var placeholder = document.getElementById("placeholder");
placeholder.setAttribute("src",source);
}
</script>
这是把脚本写在内部的方法
-->
<script type="text/javascript" src="showPic.js"></script>
</head>
<body >
<h1>Snashots</h1>
<ul>
<li>
<a href="1518aa12ee9284ce5d45d818364740ac.jpg" onclick="showPic(this);return false;" title="Wine Party">wine</a>
</li>
<li>
<a href="21296024e76ff4f17624bbda7dd4125e.jpeg" onclick="showPic(this);return false;"title="pretty gril">pretty gril</a>
</li>
<img id="placeholder" src="images/placeholder.gif" alt="my art gallery"/>
</ul>
<p id = "description">Choose an image.</p>
</body>
</html>
script部分
function showPic(whichpic){
var source = whichpic.getAttribute("href");
var placeholder = document.getElementById("placeholder");
placeholder.setAttribute("src",source);
var text = whichpic.getAttribute("title");
var description = document.getElementById("description");
description.firstChild.nodeValue = text;
}
新增加的功能是可以实现下面的句子的文本内容发生变化
可以从原来的Choose an image 到 你选择的图像的名字
学习的新的知识或者说是名词
- childNode
- nodeValue
- nodeType(有1 2 3 3个值,分别是元素节点,属性节点,文本节点)
- firstChild/lastChild
- onload
window
接下来打算看看js
再把大话数据结构看了
再接着就是操作系统的data structure
come on!