Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 920753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:46:12+00:00 2026-05-15T18:46:12+00:00

I’ve just started learning jQuery/javascript, so this might seem like a really basic question,

  • 0

I’ve just started learning jQuery/javascript, so this might seem like a really basic question, but it’s annoying me nevertheless.

I have a panel of 6 <li>s, 3 of which are hidden until clicking on the ‘view more’ link at which point the panel toggles to reveal the other 3. The icon is changing from ‘more’ to ‘less’, but then not changing back to ‘more’. Can anyone see the problem in the code?

Any help would be greatly appreciated 🙂

Thanks,
David

$(document).ready(function() {
  $('.allApps').hide();
  $('.moreAppsIcon').click(function() {
    $('.moreAppsIcon').removeClass("moreAppsIcon").addClass("lessAppsIcon");
    $(this).toggleClass("active");
    $('.allApps').slideToggle("slow");
    return false;
  });

  $('.lessAppsIcon').click(function() {
    $('.appsMore').slideToggle("slow", function () {
      $('.appsMore').removeClass("appsMore").addClass("moreAppsIcon");
      $(this).toggleClass("active");
      return false;
    });                             
  });
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:46:13+00:00Added an answer on May 15, 2026 at 6:46 pm

    It’s easier to use .live() here, like this:

    $('.moreAppsIcon').live('click', function() {
    //and...
    $('.lessAppsIcon').live('click', function() {
    

    Otherwise your functions aren’t being bound correctly. For example $('.lessAppsIcon') finds elements with that class at that time and binds a click handler to them…elements getting that class later don’t get that click handler, whereas .live() works on the selector of the element at the time of the event, having the result you want.

    So basically you’re attaching n event handlers, one for each element matching initially…when you do .addClass() the other elements don’t get that event handler all the sudden, it’s on the DOM elements you initially found, not dynamically added to others when they change class. For the same reason .removeClass() doesn’t remove the event handler. However, if you use .live() like above, it’ll have the effect of changing event handlers like you’re after.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.