JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<title>Mengubah Attribut Elemen HTML dengan Javascript</title>
</head>
<body>
<a href="https://google.com" id="myGoogle">Buka Google.com</a>
<button type="button" onclick="ubah();">Ubah Attribut</button>
<script type="text/javascript">
function ubah() {
var a = document.getElementById('myGoogle');
a.href = "https://google.co.id";
}
</script>
</body>
</html>