// 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) {
mainLink.click();
}
}
this.addEventListener("click", handleClick);
});
};