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

  • Home
  • SEARCH
  • 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 8202011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:00:58+00:00 2026-06-07T07:00:58+00:00

I am having problem with my jquery code, I am trying to state that

  • 0

I am having problem with my jquery code, I am trying to state that if “Yes” button is on, disable the “No” button, else if the “No” button is on, then disable the “Yes” button, else enable both buttons.

But at the moment do button is being disabled when the other button is turned on, does anyone know why this is?

Below is code:

function btnclick(btn)
{
    var context = $(btn).parents('#optionAndAnswer');
    if (context.length == 0) {
        context = $(btn).parents('tr');
    }

$(btn).toggleClass("answerBtnsOff");
$(btn).toggleClass("answerBtnsOn");

    if ($("#answerYes", context).hasClass('.answerBtnsOn')) {
        $("#answerNo", context).attr("disabled", "disabled");
    }

    else if ($("#answerNo", context).hasClass('.answerBtnsOn')) {
        $("#answerYes", context).attr("disabled", "disabled");
    }

    else {
    $("#answerYes", context).removeAttr("disabled");
    $("#answerNo", context).removeAttr("disabled");
    }


    return false;
}

below is html for both yes and no buttons:

Yes button:

<input class="answerBtns answers answerBtnsOff" name="answerYesName"   id="answerYes"   type="button"   value="Yes"     onclick="btnclick(this);"/>

No Button:

<input class="answerBtns answers answerBtnsOff" name="answerNoName"    id="answerNo"        type="button"   value="No"      onclick="btnclick(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-06-07T07:01:01+00:00Added an answer on June 7, 2026 at 7:01 am

    You dont put the . in toggleClass/hasClass/removeClass/… you only use them in selectors

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

Sidebar

Related Questions

I'm trying to create a tooltip with jquery. However I'm having a problem that
I am having a very specific problem in JQuery The code below is used
The following code is having some problem with the jQuery. <script type="text/javascript"> $(window).load(function() {
I am having some problem with jsonp and jquery. This is my code -
I'm having a problem with a jQuery form that I'm working on at the
I am having a problem trying to use the prependTo() function in jQuery... for
I’m having a problem trying to detect if a table exists using jQuery. The
Greetings. I'm having a weird problem with jQuery on my website. I'm trying to
I'm trying ComponentOne and I'm having a problem with jQuery. I'm working en ASP.NET
Hello guys! I have been trying to create a if/else statement code in jQuery

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.