Forums

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

Home Forums JavaScript Trouble with adding/removing a class in Jquery

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #31954
    scottjraney
    Member

    I am trying to make a navigation menu that when a link is clicked, loads content into a hidden div, then shows the hidden div, then changed the class of the list item. If the same link is clicked again the class reverts back to what it was before and then the content div becomes hidden.

    Here is a url view-source:http://www.scottjraney.com/javatest/

    Here is the Jquery

    $(document).ready(function(){

    $(“a.1”).click(function(){
    $(“div#hidden”).load(“/javatest/content1.html”);
    $(“div#hidden”).slideDown();
    $(“a”).removeClass(“1”).addClass(“1-change”);
    });
    $(“a.1-change”).click(function(){
    $(“div#hidden”).slideUp();
    $(“a”).removeClass(“1-change”).addClass(“1”);
    });
    });

    How can I get this to work?

    #55982

    I think this might be what you’re looking for:







    #55966
    scottjraney
    Member

    That is getting closer. Here is an updated version of how I see it working.

    http://www.scottjraney.com/javatest

    Now my problem is after clicking links a few times the navigation starts doing strange things.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.