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 7077015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:22:13+00:00 2026-05-28T06:22:13+00:00

Basically I have a drop icon, which should expand and collpase an area beneath

  • 0

Basically I have a drop icon, which should expand and collpase an area beneath it. It changes the background position and points downwards and shows some content.On click again it collapses the content and changes the background position. below is what i have written but it doesn’t work properly.

$(function() {
    $(".aclass").live('click' , function() {
        $(this).css("background-position","-156px -42px").addClass("new");

        $(".blockedDiv").hide();
        $(".mystery").css("max-height","189px");
    });

    $(".new").live('click', function() {
        $(this).css("background-position","0px 0px");
        $(".blockedDiv").show();
        $(".mystery").css("max-height","1007px");
    });
});

My two questions:
1: Why is this working only for one Iteration
2: Is there a better way to achieve this.

  • 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-28T06:22:14+00:00Added an answer on May 28, 2026 at 6:22 am

    You’re not removing the new class you added. Because of that, when you click on it again, the second event handler fires as well, reversing what the first event handler did.

    As a side note-slash-tip, what you want is to specify explicit CSS rules, which you can toggle with jQuery, so that you don’t have to muck through (relatively) complicated logic.

    .mystery { max-height:10007px; }
    .mystery.flagged { max-height:189px; }
    
    .aclass { background-position:0 0; }
    .aclass.flagged { background-position:-156px -42px; }
    

    then in your jQuery:

    $('.aclass').live('click', function () {
        $('.mystery').toggleClass('flagged');
        $(this).toggleClass('flagged');
        $('.blockedDiv').toggle();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a drop down list which is populated with text and values
Basically I have a form which right now has 2 drop downs with weights
I basically have a page which shows a processing screen which has been flushed
I have a drop down that has the years basically 2011,2010,2009 etc... and there
Basically what I need to know is this: I have to show a drop
Basically, I have a class defined in my website which contains a bunch of
I have a script, which basically looks like this (the part I need help
Basically, I have a drop down list and a dynamically added user control. The
So, basically I have this select / drop down menu that I use AJAX
I have a draggable div of which when you drop it, it gives you

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.