<html lang="en">
<head>
<meta charset="utf-8">
<title>Javascript Getting Element's Attribute Value</title>
</head>
<body>
<a href="https://www.google.com/" target="_blank" id="myLink">Google</a>
<script>
// Selecting the element by ID attribute
var link = document.getElementById("myLink");
// Getting the attributes values
var href = link.getAttribute("href");
alert(href); // Outputs: https://www.google.com/
var target = link.getAttribute("target");
alert(target); // Outputs: _blank
</script>
</body>