<!DOCTYPE html>
<html>
<body>
<p><a id="myAnchor" target="_blank" href="../../www.example.com/test.htm#part2">Example link</a></p>
<p>Click the button to change the anchor part of the link above.</p>
<p><b>Tip:</b> Open the link and look in the address bar before and after you have clicked the "Try it" button, to see the effect.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("myAnchor").hash = "newhashvalue";
document.getElementById("demo").innerHTML = "The anchor part was changed from '#part2' to '#newhashvalue'";
}
</script>
</body>
</html>