atribut href HTML DOM Jangkar
Definisi dan Penggunaan
set properti href atau mengembalikan nilai dari atribut link href.
Atribut href menentukan URL adalah sumber terkait.
tatabahasa
Mengatur atribut href:
anchorObject.href="URL"
Kembali atribut href:
anchorObject.href
值 | 描述 |
---|---|
URL | 被链资源的 URL |
Dukungan Browser
Semua browser utama mendukung atribut href
contoh
contoh
Kembali Nilai menghubungkan atribut href:
<html>
<body>
<p><a id="w3s" href="http://www.w3cschool.cc/">W3Schools.com</a></p>
<script>
document.write(document.getElementById("w3s").href);
</script>
</body>
</html>
<body>
<p><a id="w3s" href="http://www.w3cschool.cc/">W3Schools.com</a></p>
<script>
document.write(document.getElementById("w3s").href);
</script>
</body>
</html>
Contoh output di atas:
http://www.w3cschool.cc/
Coba »
objek anchor