obtener el estado actual de la casilla de verificación jquery [duplicado]

estoy usando Bootstrap compruebo plugin. How can i find out Whether a check box is checked or not by pressing a button using jquery

$(button).click(function(){

  ckb = $("#ickb").(isChecked);
});

preguntado el 28 de mayo de 14 a las 13:05

Starting jquery 1.6 there have been significant changes the way attributes and properties are dealt with. For your case $('#ickb').prop("checked") should do the trick. This statement will simply return true or false depending upon the checked/unchecked state of the check box. For more details refer to attributes vs. properties section on así Enlace. -

2 Respuestas

Tratar de usar .is() funcionar junto con :checked selector to accomplish your task,

ckb = $("#ickb").is(':checked');

contestado el 28 de mayo de 14 a las 13:05

Utilice la herramienta es() :comprobado to get the result as boolean that is true if checkbox is checked.

ckb = $("#ickb").is(':checked');

Or, you can use length, if it is cero then it is not checked.

ckb = $("#ickb:checked").length

Respondido 29 Abr '22, 22:04

The second option is a single column like so $("#ickb:checked").length Your answer helped me - Michael Oshosanya

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.