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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:42:37+00:00 2026-06-04T04:42:37+00:00

I have four buttons which has click able property. Clicking on button will make

  • 0

I have four buttons which has click able property. Clicking on button will make a div slide down and clicking again on same div should close the div. I want to add a condition like, when I have a div open, the click property on rest of the three buttons should be disabled, what I did is

for (var i = 1; i <= 4; i++) {
    $(".slide" + i).click(function () {
        var openTab = $(this).attr('class');
        openTab = openTab.replace('slide', '');
        var facetGroup = $(this).attr("key");
        if ($('#panel').is(':visible')) {
            buttonCloser(openTab);
        } else {
            buttonOpener(openTab, facetGroup);
        }
    });
}

function buttonCloser(m) {
    for (var j = 1; j <= 4; j++) {
        if (j != m) {
            //alert(j);
            $(".slide" + j).bind("click");
        } else {
            $(".slide" + j).css({
                "background-color": " #fff5c3",
                "color": "#000000"
            });
        }
    }
    $("#panel").slideUp("slow");
}

function buttonOpener(m, n) {
    for (j = 1; j <= 4; j++) {
        if (j != m) {
            $(".slide" + j).unbind("click");
        } else {
            $(".slide" + j).css({
                "background-color": "#293345",
                "color": "#fff5c3"
            });
        }
    }
    $("#panel").slideDown("slow");
    refreshFacet(n);
}

The problem with this code is that the first time I open a div by clicking on slider, the other three click events are disabled, bt when I close that div, it will nt re-enable its click property. so it wont open anything..

  • 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-06-04T04:42:39+00:00Added an answer on June 4, 2026 at 4:42 am

    Without seeing your actual mark-up, I’d suggest that you use simple jQuery, rather than mixing and matching between ‘plain’ JavaScript and jQuery:

    var buttons = $('button[class^="slide"]'),
        panel = $('#panel');
    
    $(buttons).click(
        function() {
            var that = $(this);
            if (panel.is(':visible')) {
                if (that.hasClass('opener')) {
                    panel.slideToggle();
                    that.removeClass('opener');
                }
                else {
                    return false;
                }
            }
            else {
                panel.slideToggle();
                that.addClass('opener');
            }
        });​
    

    JS Fiddle demo.


    References:

    • addClass().
    • attribute begins with selector attribute^="value" selector.
    • hasClass().
    • removeClass().
    • slideToggle().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a partial view which has dual list boxes and four buttons; exactly
I have one activity Select which has four buttons and other activity Result. Now
I currently have a view with four buttons, and would like to be able
On the page I am building, I have four buttons which show/hide (visible=true ||
I have implement one application in which four image button and on image button
I have four buttons, which have to push the same uiTableViewController, with different data
I have map application in which I have four buttons for Zoom In, Zoom
So, I have a DIV full of four HTML buttons that use an image
I have four Buttons that display the the date/time of calendars which are attributes
I have an Android application which has four tabs (I use a main TabActivity

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.