jQuery: Adding a class to <a> element

I have a WordPress site and I would like to add a class to the links in the main navigation using jQuery.

This is how the code currently looks:

Read More

HTML

<div class="nav-menu">
<ul>
<li class="current_page_item">
<a title="Home" href="www.example.com">Home</a>
</li>
...
</ul>
</div>

And this is what I’d like to achieve:

HTML

<div class="nav-menu">
<ul>
<li class="current_page_item">
<a title="Home" href="www.example.com" class="new-class-goes-here">Home</a>
</li>
...
</ul>
</div>

Does anyone have a clue how to do this?

Related posts

Leave a Reply

1 comment