Do you mean in post content and you want it to happen automatically without you having to enter the class manually? Can you do it in JavaScript or does it have to happen on the backend?
Thread Starter
Takius
(@takius)
I want to do it automatically, when i use the anchor button in the editor menu.
Actually, i use a JavaScript solution, but i dont tell “no” for other tips.
Hi Takius
Here, you have the only option is using javascript. It will add the class to all anchor links.
For those who is looking for a solution:
jQuery(function($) {
$('a').each(function() {
$(this).addClass('NEW_CLASS_NAME');
});
});
Ashok’s answer is good, but you don’t need the each iteration:
jQuery(function($) {
$('a').addClass('NEW_CLASS_NAME');
});
The above will work just as well and is less code to understand and maintain.
Ahh yes, we don’t need iteration 🙂