Skip to content

Instantly share code, notes, and snippets.

@arafatjamil01
Last active February 5, 2022 12:55
Show Gist options
  • Save arafatjamil01/718e0a3653a0092d3af8a7887535b6b8 to your computer and use it in GitHub Desktop.
Save arafatjamil01/718e0a3653a0092d3af8a7887535b6b8 to your computer and use it in GitHub Desktop.
Find all the links on a webpage or empty links
// 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