Reputation: 1227
I am trying to manipulate the following lines using jQuery:
<a href="#section-one"><div class="section-dots active-section"></div></a>
<a href="#section-two"><div class="section-dots"></div></a>
<a href="#section-three"><div class="section-dots"></div></a>
<a href="#section-four"><div class="section-dots"></div></a>
How can I get the anchor element by an href, for example #section-one
, and then update the next element with the class "active-section"
?
Upvotes: 0
Views: 44
Reputation: 4475
Something like this should work for you. You may have to alter this code a bit.
$(".active-section").removeClass("active-section");
$( "a[href='#section-one']" ).next().addClass( "active-section" );
https://api.jquery.com/category/selectors/
Upvotes: 0
Reputation: 18669
Your question is worded very vaguely, but hopefully this answers it.
how can I get the element by a href ... i.e. #section-one
$('[href="#section-one"]')
and then update the next element class with "active-section"
$('[href="#section-one"]').next().addClass('active-section')
Upvotes: 2