双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

JS的一些小问题 求大神解答

weixin_40980353 weixin_40980353 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>图片库</title>
<style>
#placeholder{
height: 500px;;
width: 500px;
border: 1px solid black;
}
</style>
</head>
<body>
<h1 title="This is title">Snapshots</h1>
<ul>
<li id="liid">
<a href="案例研究/1.JPG" title="A fireworks display" onclick="showPic(this); return false;">Fireworks</a>
</li>
<li>
<a href="案例研究/2.JPG" title="B fireworks display" onclick="showPic(this); return false;">Coffee</a>
</li>
<li>
<a href="案例研究/3.JPG" title="C fireworks display" onclick="showPic(this); return false;">Rose</a>
</li>
<li>
<a href="案例研究/5.JPG" title="D fireworks display" onclick="showPic(this); return false;">Big Ben</a>
</li>
</ul>
<img id="placeholder" src="案例研究/155537pb4aaxk4abawq555.jpg" alt="My image Gallery">
<P id="description">This is my picture.</P>
<script src="scripts/showPic.js" type="text/javascript"></script>
</body>
</html>

js:
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;
}
为什么在我执行了 description.firstChild.nodeValue=text;之后,点击链接会发生跳转啊?
我已经在onclick里面添加了return false了
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
weixin_40980353
JavaScript 87,983 成员 224,680 内容