Snippets Collections
function footerNavTracking() {
        const footerWrapper = document.querySelector(".footer__wrapper");
        if (!footerWrapper) return;

        footerWrapper.addEventListener("click", (e) => {
            // Find the closest relevant link
            const link = e.target.closest(
                ".footer__col-second-button_wrapper a, .footer__logo-link",
            );
            if (!link) return;

            e.preventDefault();

            // Get the URL from the <a> tag
            const url = link.getAttribute("href") || "";

            // Social links
            if (link.matches(".footer__col-second-button_wrapper a")) {
                // Get the visible text (after the span/SVG)
                const linkTextRaw = link.lastChild.textContent.trim();
                const linkText = linkTextRaw.replace(/\s+/g, " ").trim() || "";

                gtmPush({
                    event: "navigation_click",
                    navigation_type: "footer_nav",
                    click_text: linkText,
                    click_url: url,
                    level: 1,
                });
            }

            // Logo links
            if (link.matches(".footer__logo-link")) {
                const linkTextRaw =
                    link.querySelector("svg title")?.textContent || "";
                const linkText = linkTextRaw.replace(/\s+/g, " ").trim() || "";
                const url = link.getAttribute("href") || "";

                gtmPush({
                    event: "navigation_click",
                    navigation_type: "footer_nav",
                    click_text: linkText,
                    click_url: url,
                    level: 1,
                });
            }
        });
    }
   const sibling = el.previousElementSibling; // parent wrapper
    
      if (sibling) {
        const classList = sibling.getAttribute('class');
        if (classList !== null && classList !== undefined && classList !== '') {
          if (sibling.classList.contains(navLinkClass)) {
           	// do something
          }
        }
      }
cell.cellButton.tag = indexPath.row
            cell.cellButton.addTarget(self, action: #selector(yourFunc(sender:)), for: UIControl.Event.touchUpInside)
                                                            
@objc func yourFunc(sender: UIButton){
    let buttonTag = sender.tag
}
document.addEventListener("click", e => {
if(e.target.matches(".clase")||e.target.matches(`${".clase"} *`)) {
  
  ...
}
})

/* Otro */

  document.addEventListener("click", (e) => { 

        if(e.target.classList.contains("desplegable") || e.target.parentElement.classList.contains("desplegable")) {

            document.querySelector(".filtros-desplegables").classList.toggle("is-active");
        }
        
      })
  
star

Wed Jan 07 2026 05:48:40 GMT+0000 (Coordinated Universal Time)

#matches() #click #event
star

Wed Oct 11 2023 05:36:53 GMT+0000 (Coordinated Universal Time)

#javascript #ignorewrapper #click
star

Mon Dec 05 2022 15:28:43 GMT+0000 (Coordinated Universal Time) https://github.com/0x29a/cli_template

#cli #click
star

Sun Oct 31 2021 19:12:46 GMT+0000 (Coordinated Universal Time)

#click

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension