Sometimes, we want to get local href value from anchor (a) tag with JavaScript.
In this article, we’ll look at how to get local href value from anchor (a) tag with JavaScript.
How to get local href value from anchor (a) tag with JavaScript?
To get local href value from anchor (a) tag with JavaScript, we can use the href
property.
For instance, we write
const href = document.getElementById("aaa").href
to get the anchor element with ID 'aaa'
with getElementById
.
And then we get the href attribute value with href
.
Conclusion
To get local href value from anchor (a) tag with JavaScript, we can use the href
property.