Categories
JavaScript Answers

How to get local href value from anchor (a) tag with JavaScript?

Spread the love

To get local href value from anchor (a) tag with JavaScript, we use the href property.

For instance, we write

const href = document.getElementById("aaa").href;

to select the link with ID aaa with getElementById.

And then we get its href attribute value with the href property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *