Without having a href
, the click will reload the current page, so you need something like this:
<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:
<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>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…