Answers for "js get href of a element"

1

get href attribute javascript

document.getElementById("link")[0].getAttribute("href");
Posted by: Guest on March-07-2020
0

check href javascript

// CHECK HREF
const navLinks = document.querySelector(".nav_link");
const navLink = navLinks.getAttribute("href");
const browserHref = window.location.href; // browserHref.search(navLink)

function sliceLink() {
   if (browserHref.includes(navLink)) {
     let searchLink = browserHref.search(navLink); // get position
     let slicedString = browserHref.slice(searchLink); // result
     return slicedString;
   }
}
Posted by: Guest on August-30-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language