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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:03:46+00:00 2026-06-18T10:03:46+00:00

How can I disable a jquery function using an if else statement. My problem

  • 0

How can I disable a jquery function using an if else statement.
My problem is that I have two text boxes that open onClick, they are set to toggle, but how can I set it so that if one of the boxes is open, the other one won’t open
My jquery is

$(".first1").on('click', 
  function () {
    $('#suitsyou').toggle();
  });
$(".last1").on('click', 
  function () {
      $('#dealsandoffers').toggle() 
  });

It may be easier to look at my website http://www.jeremyspence.net78.net it is in the packages tab, you can see that when you click on one tab and then the other without closing the first they both open

the html is

    <div id="suitsyou" style="display:none">

    </div>

    <div id="dealsandoffers" style="display:none"> 

    </div>

Content was not included so not to put so much code in

  • 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-18T10:03:47+00:00Added an answer on June 18, 2026 at 10:03 am

    A simple conditional should work:

    $(".first").on('click', function () {
        if (!$("#dealsandoffers:visible").length) {
            $("#suitesyou").toggle();
        }
    });
    

    Use classes if you need more flexibility than that. This also isn’t particularly user friendly. Seems to me like you would want to close the other and then show the one that was currently clicked.

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

Sidebar

Related Questions

I have jNiceIT plugin for Jquery. How can i disable the select dropdown styled
plz guide me how I can enable or disable asp.net validation controls using jQuery
How can I disable an input-field with jQuery using GM if the url contains
I have a problem with the jquery $.get function. I'm trying to get data
I have a simple jquery.hide() function that is on all the divs with a
I have built a function using jQuery to insert into a table a new
I have an AJAX request (using JQuery) that calls a PHP script which does
I can disable one and one by doing this: jQuery('#ListBoxA').attr('disabled','true'); But how can I
How can I disable the header click for jQuery tabs. I only want to
Can I disable the minimize button in JFrame? I have already tried setUndecorated() and

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.