Grow your CSS skills. Land your dream job.

[Solved] Jquery Click help

  • # October 23, 2010 at 4:52 pm

    Hello everyone. Can anyone tell me what I’m doing wrong here. I have a simple navigational menu buil with a anchor nested in a ul li. I am trying to add a background when the item is clicked with jQuery but nothing happens. Here is the code:








    It does something a little wierd. When you click on the link the background will kind of flicker real quick on all the anchors but nothing stays. I do have jquery working as there is more code ive just condensed it for you all. Any and all help is greatly appreciated.

    # October 23, 2010 at 5:24 pm

    try this:

    $('#header ul li a').each(function() {
    $(this).click(function(){
    $(this).addClass('navActive');
    });
    });
    # October 23, 2010 at 5:34 pm

    Thanks marc I tried your script and nothing. Again it flickers then gone just as fast.

    # October 23, 2010 at 5:58 pm

    Do you have a live example of the problem?

    # October 23, 2010 at 6:57 pm

    I do not I will try to get one up

    # October 23, 2010 at 10:32 pm

    Issue solved thanks for the help. It was what I thought something stupid simple. Gotta prevent default. The browser was reloading the page when a link was clicked. Lol such a noob. Thanks @ryanolson

    # October 23, 2010 at 11:14 pm

    Lol, it’s usually the simplest of issues.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".