<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<a id="myLink" href="https://www.example.com" target="_blank">Visit Example</a>
<button id="setAttrBtn">Change Link</button>
<script>
$(document).ready(function() {
$("#setAttrBtn").click(function() {
$("#myLink").attr("href", "https://www.google.com");
$("#myLink").text("Visit Google");
});
});
</script>
</body>
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.