showing results for - "check href javascript"
Iliana
14 Oct 2018
1// CHECK HREF
2const navLinks = document.querySelector(".nav_link");
3const navLink = navLinks.getAttribute("href");
4const browserHref = window.location.href; // browserHref.search(navLink)
5
6function sliceLink() {
7   if (browserHref.includes(navLink)) {
8     let searchLink = browserHref.search(navLink); // get position
9     let slicedString = browserHref.slice(searchLink); // result
10     return slicedString;
11   }
12}