jQuery(document).ready(function () { jQuery(".value-item").on("click", function () { // Remove active class from all value items jQuery(".value-item").removeClass("active"); // Add active class to the clicked item jQuery(this).addClass("active"); // Get the data-color of the clicked item const color = jQuery(this).data("color"); // Find the next arrow sibling and set its color const jQuery(arrow) = jQuery(this).next(".arrow"); if (jQuery(arrow.length)) { jQuery(arrow).css({ "background-color": color, "border-color": color }); } }); });