This article mainly introduces the relevant knowledge of jQuery to implement the radio first click to select and the second click to cancel function, which has a good reference value. Let's take a look with the editor below, I hope it can help everyone.
Due to the needs of the project, the radio is required to be in a canceled state after being clicked twice. It is inconvenient to change it to a checkbox. It can be achieved with a positive method.
// jquery $('input:radio').click(function(){ //alert(this.checked); // var $radio = $(this); // if this was previously checked if ($radio.data('waschecked') == true){ $radio.prop('checked', false); $radio.data('waschecked', false); } else { $radio.prop('checked', true); $radio.data('waschecked', true); } });
Related recommendations:
jQuery gets the radio button selected value and removes all radio selected status examples to share
jQuery implements RadioButton to do the required verification function method sharing
The above is the detailed content of How to implement radio's first click to select and second click to cancel. For more information, please follow other related articles on the PHP Chinese website!