• Hello,

    I want to add class for all my anchor, but i dont have any clue how to do it.

    More precisely, i want this :
    <a name="RefDeLAncre"></a>
    become this:
    <a class="Ancre" name="RefDeLAncre"></a>

    Thanks for your help.
    Takius.

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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.

    Ashok

    (@bappidgreat)

    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.

    Ashok

    (@bappidgreat)

    Ahh yes, we don’t need iteration ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add class to a anchor’ is closed to new replies.