Without having a href
, the click will reload the current page, so you need something like this:(没有href
,点击将重新加载当前页面,所以你需要这样的东西:)
<a href="#" onclick="f1()">jhhghj</a>
Or prevent the scroll like this:(或者像这样阻止滚动:)
<a href="#" onclick="f1(); return false;">jhhghj</a>
Or return false
in your f1
function and:(或者在f1
函数中return false
并且:)
<a href="#" onclick="return f1();">jhhghj</a>
....or, the unobtrusive way:(....或者,不引人注目的方式:)
<a href="#" id="abc">jhg</a>
<a href="#" id="myLink">jhhghj</a>
<script type="text/javascript">
document.getElementById("myLink").onclick = function() {
document.getElementById("abc").href="xyz.php";
return false;
};
</script>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…