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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:18:50+00:00 2026-06-13T08:18:50+00:00

check out this fiddle: http://jsfiddle.net/5rmEe/61/ var inputVal = false; //allow user to deselect a

  • 0

check out this fiddle: http://jsfiddle.net/5rmEe/61/

    var inputVal = false;
    //allow user to deselect a radio button by clicking a checked radiobutton
    $('input[type=radio]').each(function(){
      var inputObj = $(this);
      inputObj.click(function(e){
        if(inputVal === inputObj.val()){
          inputVal = false;
          inputObj.attr('checked', false);
        }
        else{
          inputVal = inputObj.val();
          inputObj.attr('checked', 'checked');
        }
        e.stopPropagation();
      });
    });

$('.asdf').click(function(){
    $('.haha').trigger('click');
});

notice that the asdfsdaf span would trigger a click on the radio button

First of all, the radio button is set such that if you click on a checked radio button it will uncheck itself (try it out) and this works when clicking on the radio button itself

now If you click on the span, it’ll make the checkbox check itself properly but then if you click on the span again it will NOT set the radio button as unchecked even though evidently it performs a click event and theoretically it should uncheck the radio button accordingly due to the click event (this event works if you actually click on the radio button)

why is this happening? is the attr() method not working if the event is manually triggered using .trigger()?

how can I resolve this such that clicking on the span would ALSO trigger an uncheck in the radio button when the radio button is checked?

  • 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-13T08:18:51+00:00Added an answer on June 13, 2026 at 8:18 am

    Use triggerHandler instead of trigger.

    $('.haha').triggerHandler('click');
    

    This will cause the handler to be fired without causing the default behavior of the click.

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

Sidebar

Related Questions

check out this fiddle: http://jsfiddle.net/5rmEe/ the goal is to uncheck the radio button when
Check out this fiddle: http://jsfiddle.net/mattball/nWWSa/ var $lis = $('ul.innerfade > li'); function fadeThemOut() {
If you check out this JS fiddle: http://jsfiddle.net/DE5Bp and try to sort the Tariff
Check out this fiddle: http://jsfiddle.net/sajYc/ The transition for the :after pseudo element works in
Please check out this fiddle: http://jsfiddle.net/dppJw/8/ I've used a pseudo-element for the body (also
http://jsfiddle.net/4UbKe/3/ Please check out the fiddle to see exactly why it doesn't work. I'm
Please check out this http://jsfiddle.net/karthik64/JHVDn/1/ . Well I believe you got where I am
Check out this code sample from Scott Guthrie's blog: http://weblogs.asp.net/blogs/scottgu/image_43366964.png Notice item is a
In this fiddle http://jsfiddle.net/SySRb/105/ , function init(); successfully checks for the existence of an
Please have a look at this fiddle: http://jsfiddle.net/mrmartineau/53fkV/embedded/result/ The intended outcome is that when

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.