skip to Main Content

Add a class to all sibling element if one of the element gets that same class when clicked? – Javascript

const images = document.querySelectorAll(".img_items"); images.forEach((image) => { image.addEventListener("click", () => { image.classList.add("select"); }); }); .img_items::after{ content: ' ' attr(class) } <div class="img_container"> <div class="img_items ">1</div> <div class="img_items ">2</div> <div class="img_items">3</div> <div class="img_items">4</div> </div> I tried adding the class to the…

VIEW QUESTION

Get a list of siblings term ids from current product category in WooCommerce

I want to retrieve a list of term Ids based on the current category ID. At the moment I'm using the following code: $product_cat_items = get_queried_object(); $product_cat_id = $product_cat_items->term_id; $product_cat_child = get_term($product_cat_id, 'product_cat'); $product_cat_parent = $product_cat_child->parent; $product_cat_related= get_terms('product_cat', array( 'parent'…

VIEW QUESTION
Back To Top
Search