so I have something like this –
<a href="link..." class="text-box-a-href" >
<div class="text-box">
<h4>text...</h4>
<p> text....</p>
<span> date.</span>
</div>
</a>
What I need is, if someone clicks on link with class=”text-box-a-href” it automatically adds class .visited to h4.
Something like this –
$('.text-box-a-href').click(function() {
var clicked_element;
clicked_element = $(this);
$(clicked_element).children('h4').addClass('visited');
});
But nothing happens. On homepage I got like 10000 elements with so you know.
Thanks.
I’m not 100% sure what you’re trying to do. But the page will just reload using that script. The class will get added, then the page reloads and the DOM get’s rebuilt.