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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:56:11+00:00 2026-05-23T17:56:11+00:00

This is my jQuery script: $(input[type=radio]:checked).live(click, function() { $(this).attr(checked,false); }); I want to make

  • 0

This is my jQuery script:

$("input[type=radio]:checked").live("click", function() {
    $(this).attr("checked",false);
});

I want to make all my radio button can be checked and unchecked. The code suppose to trigger ONLY when checked radio being clicked. But somehow, any radio click (whether it’s checked or not) will trigger this event. It’s as if the browser will check the radio first and then run my script.

If I alert($("input[type=radio]:checked").size()), it gave me the correct count.

I’m testing the code in FF4 but I hope the solution can cater for IE as well.

Ok, since my question seems confusing, this is the working code for what I want, BUT it requires additional custom attribute which I hope can avoid.

<input type="radio" name="group1" value="1" isChecked="false"/>
<input type="radio" name="group1" value="2" isChecked="false"/>
<input type="radio" name="group1" value="3" isChecked="false"/>

<script>

$(document).ready(function(){
    $("radio").click(function(){
        if($(this).attr("isChecked")=="false"){
            $(this).attr("isChecked","true");
            $(this).attr("checked",true);
        }
        else{
            $(this).attr("isChecked","false");
            $(this).attr("checked",false);
        }
    });
});

</script>
  • 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-23T17:56:11+00:00Added an answer on May 23, 2026 at 5:56 pm

    This isn’t really the way that radio buttons are intended to be used. It seems like you are trying to create an input control that’s somewhere between a radio button and a checkbox.

    There are a couple of approaches you could take:

    1) Use a separate button to clear the radio buttons:

    The HTML:

    <input id="clearRadios" type="button">Clear</input>
    

    The jQuery:

    $('#clearRadios').click(function() {
        // use attr only if you're using an older version of jQuery
        $('input[type=radio]').prop('checked', false);
    });
    

    2) Use checkboxes rigged to work like radio buttons:

    var $chkboxes = $('input[type=checkbox]');
    $chkboxes.click(function() {
        var currChkbox = this;
        $chkboxes.each(function() {
            if (this !== currChkbox) {
                $(this).prop('checked', false);
            }
        });      
    });
    

    If it were me, I’d probably go with the first option in most circumstances.

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

Sidebar

Related Questions

I have this jQuery code: <script type=text/javascript > $(function() { $('#add_comment').bind('submit',function() //$(input[type=submit]).click(function() { var
Here is my jQuery code: <script type=text/javascript> //<!-- $(document).ready(function() { $('input[type=submit]').click(function() { $.ajax({ type:
is this a valid JQuery usage pattern to : <script type=text/javascript> $(body).prepend('<input type=hidden id=error
how can I make this jquery script close all previously opened children when entering
This is how I load jQuery: <script src=http://www.google.com/jsapi></script> <script type=text/javascript> function OnLoad() { insert
main.php: <SCRIPT type=text/javascript> $(#btnSubmit).click(function () { alert(What will i put here!); }); </SCRIPT> <input
I have this at the top of my jQuery script: $().ajaxStart(function() { alert('ok'); });
$(function(){ $('a').each(function(){ var x=this.href; this.href=www.somesitename.com/filter+this.href; }); }); i wrote the above jQuery script to
I used to use this script for jquery email obfuscation: $(.replaceAt).replaceWith(@); $(.obfuscate).each(function () {
I've got this bit of JQUERY: <script> function initNav() { $('.nav tr table td

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.