Home > Article > Web Front-end > How to search the value of a link's href attribute in JavaScript?
#To get the href attribute value of a link in JavaScript, use the href attribute. It can give the URL of the linked document in JavaScript.
You can try running the following code to get the href attribute value of a link.
Online Demo
<!DOCTYPE html> <html> <body> <p><a id="anchorid" href="https://www.qries.com/">Qries</a></p> <script> var myLink = document.getElementById("anchorid").href; document.write("Link: "+myLink); </script> </body> </html>
The above is the detailed content of How to search the value of a link's href attribute in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!