Manipulating Radiobutton to have no value in any field

Asked

Viewed 163 times

2

I need your help: I have two radiobutton, and I wanted to turn them into checkbox, only I can not change the type for checkbox, on this radio I could make to select and to remove if you want.

Could someone help me?

  • 1

    Very careful with these "differentiated" components, users are used to a specific operating pattern of each component and they will require that this pattern does not change... just a hint . the.

  • @Marioaleo Thanks for the tip!

1 answer

0


Leonardo,

Put one of these options on your radiobutton onClick:

this.checked = false;
$(this).prop('checked', false);
$(this).attr('checked', false);
$(this).removeAttr('checked');

If placed in a separate javascript you can replace this for '#idRadioBtn'

It is also possible to search for all radio elements:

$("input:radio").attr("checked", false);
$("input:radio").removeAttr("checked");

The above operations are for cancel the selected element, to do otherwise simply change the parameters false for true.

You may need a control logic. To check which state the element uses:

document.querySelector('input[name="nomeSeuRadio"]:checked').value;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.