หากต้องการค้นหาค่าแอตทริบิวต์เป้าหมายของลิงก์ใน JavaScript ให้ใช้ เป้าหมาย คุณสมบัติ. คุณสามารถลองเรียกใช้รหัสต่อไปนี้เพื่อรับค่าแอตทริบิวต์เป้าหมาย
ตัวอย่าง
<!DOCTYPE html>
<html>
<body>
<p><a id = "qriesid" target="_self" href = "https://qries.com/" type = "text/html" >Qries</a></p>
<script>
var x = document.getElementById("qriesid").target;
document.write("Value of the target attribute: "+x);
</script>
</body>
</html>