Can someone help me figure out how to add a class to all elements that have the same href as a clicked anchor tag?
I understand how to add a class to one element, but I'm unsure about adding a class to multiple elements with the same href.
$('.shop-item').on('click', function(e){
var hrefClicked = $(this).attr('href');
var otherElem = $('a[href$='+hrefClicked+']').attr('href');
alert(otherElem);
//$(this).addClass('newClass');
});
UPDATE:
Here is an example of the HTML structure:
<ul class="shop-list">
<li class="shop-item"><a href="#Ordering"></a></li>
<li class="shop-item"><a href="#Delivery"></a></li>
....
</ul>