Card links – jQuery

// makes all areas in card have one link
if ($('.card').length > 0) {
  $(".card").each(function() {
    const card = this.querySelector(".card");
    const mainLink = this.querySelector(".card-link");
    const clickableElements = Array.from(this.querySelectorAll("a")); //we are using 'a' here for simplicity but ideally you should put a class like 'clickable' on every clicable element inside card(a, button) and use that in query selector
    clickableElements.forEach((ele) =>
    ele.addEventListener("click", (e) => e.stopPropagation())
  function handleClick(event) {
    const noTextSelected = !window.getSelection().toString();
    if (noTextSelected) {;
  this.addEventListener("click", handleClick);

Search the site

Share this page:


Subscribe to get regular news and updates

  • This field is for validation purposes and should be left unchanged.