Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Add a class on click event

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #32612

    Hi
    I want to add a class on a click event:

    $(‘#nav a’).click(function(){
    $(this).addClass(‘select’);
    });

    The class ‘select’ is to change the look of that #nav a so that it helps the visitor to know on what page they are…
    The code work but the class is added on during the click and then it disapears. How can I do so that it stays even after the click…??
    Thanks

    #47036

    I am using wordpress for my site… is there a conflict??? I see that it works on links that I’ve set to a href=”#” but not on links that are active…???
    Thanks

    #46977

    Sounds like you’re trying to style the navigation tab for the current page?
    If you’re building the navigation dynamically, WP adds the class “current_page_item” to the appropriate li tag automatically that you can style.

    #123787
    Bipin Kumar Pal
    Participant

    Hi all

    I am useing this code mobile apps not add class in a:link

    Please help me

    #123783
    Paulie_D
    Member

    @vipinisvest01 I think we need more information but please start a new thread rather than resurrecting one from 2 years ago that may not apply to your specific situation.

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