Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p><a id="myAnchor" href="../index.html">W3Schools</a></p>

<p>Click the button to set the value of the target attribute of the link above to "_blank".</p>

<p><b>Note:</b> Try the link before and after you have clicked the button!</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myAnchor").target = "_blank";
    document.getElementById("demo").innerHTML = "The value of the target attribute was set.";
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy