为了账号安全,请及时绑定邮箱和手机立即绑定

JS实现点击链接取消跳转效果的方法 return false;不好使,该肿么办?

JS实现点击链接取消跳转效果的方法 return false;不好使,该肿么办?

Gavin_Alison 2016-09-14 14:19:34
这里html页面<!DOCTYPE html> <html lang="en"> <head>     <meta http-equiv="content-type"  content="text/html; charset=utf-8" >     <title>Image gallery</title>     <script type="text'javascript" src="js/showPic.js"></script>     <link rel="stylesheet" href="css/layout.css" type="text/css" /> </head> <body>     <h1>Snapshots</h1>     <ul>         <li>             <a href="images/fireworks.jpg" title="A fireworks display" onclick="showPic(this); return false;">Fireworks</a>         </li>         <li>             <a href="images/coffee.jpg" title="A cup of black coffee" onclick="showPic(this); return false;">Coffee</a>         </li>         <li>             <a href="images/rose.jpg" title="A red, red rose" onclick="showPic(this); return false;">Rose</a>         </li>         <li>             <a href="images/bigben.jpg" title="The famous clock" onclick="showPic(this); return false;">Big Ben</a>         </li>              </ul>     <img id="placeholder" src="images/placeholder.gif" alt="my image gallery" />     <p id="description">Choose an image.</p> </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; }现在点击链接想取消跳转效果,但是一直取消不掉,该肿么办???
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 2331 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信