87,910
社区成员
发帖
与我相关
我的任务
分享
function myjs(a) {//////////////
//var a = document.getElementById("a_pic");
var source = a.getAttribute("href");
var b = document.getElementById("b_pic");
//b.setAttribute = ("src", "source");
b.setAttribute("src", "source");
var description = a.getAttribute("title");
var text = document.getElementById("text");
text.firstChild.nodeValue = description;
}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>这个JS怎么运行不了</title>
<script type="text/javascript ">
function myjs(){
var a=document.getElementById("a_pic");
var source=a.getAttribute("href");
var b=document.getElementById("b_pic");
b.setAttribute("src",source);
var description=a.getAttribute("title");
var text=document.getElementById("text");
text.firstChild.nodeValue=description;
return false;
}
</script>
</head>
<BODY>
<li><a id="a_pic" href="1.jpg" title="我是第一张图" onClick="return myjs(this);">第一张</a></li>
<img id="b_pic" src="2.jpg" />
<p id="text">我要第一张图</p>
</BODY>
直接上代码了