radio实现第一次点击选中第二次点击取消

Jquery代码如下:



   
   
  1. $( "#add_form .radio input").bind( "click", function(){
  2. var $radio = $( this);
  3. // if this was previously checked
  4. if ($radio.data( 'waschecked') == true)
  5. {
  6. $radio.prop( 'checked', false);
  7. $radio.data( 'waschecked', false);
  8. }
  9. else
  10. {
  11. $radio.prop( 'checked', true);
  12. $radio.data( 'waschecked', true);
  13. }
  14. // remove was checked from other radios
  15. $radio.siblings( 'input[type="radio"]').data( 'waschecked', false);
  16. });


猜你喜欢

转载自www.cnblogs.com/jpfss/p/9707194.html