Home > Web Front-end > JS Tutorial > href value of a tag

href value of a tag

高洛峰
Release: 2016-10-31 11:48:50
Original
1373 people have browsed it

click实验证明,页面上能不用这个值就最好不要用这个#,这个#会让你的页面瞬间滚动到页面的顶部,我不知道已经踩了多少次坑了,就是因为这个‘#’

hello这条语句跟world这条我一开始看一个博客说有一点区别,然后我就demo了一下,感觉没区别啊

上代码,你们可以测试一下

<!DOCTYPE html>
<html>
<head>
    <meta charset=&#39;UTF-8&#39;>
    <title>a</title>
</head>
<body>
<a href="javascript:;" onclick=&#39;demo()&#39;>hello</a>
<a href="javascript:void(0)" onclick=&#39;demo()&#39;>world</a>
</body>
<script type="text/javascript">
    function demo(){
        alert(&#39;hello&#39;);
    }
</script>
</html>
Copy after login

感觉一样的,但是看到有博客是这样解释的

 

a href="javascript:;" onclick="demo()"与world的区别只是执行了一条空的js代码

其实我不太懂这句话是什么意思,有哪些大神能帮忙解释一下就最好不过了


Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template