Last active
February 5, 2022 12:55
-
-
Save arafatjamil01/718e0a3653a0092d3af8a7887535b6b8 to your computer and use it in GitHub Desktop.
Find all the links on a webpage or empty links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get all the links of the webpage | |
let links = document.querySelectorAll('a'); | |
for (let i = 0; i < links.length; i++) { | |
console.log(links[i]); | |
} | |
// get all the empty links of the webpage | |
let links = document.querySelectorAll("a[href='#']"); | |
for (let i = 0; i < links.length; i++) { | |
console.log(links[i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment