Basic radio box
Te
Attach a handler to ifChanged
event:
$('input').on('ifChecked', function(event){
alert($(this).val()); // alert value
});
There are 11 ways to listen for changes:
ifClicked
- user clicked on a customized input or an assigned labelifChanged
- input's checked, disabled or indeterminate state is changedifChecked
- input's state is changed to checkedifUnchecked
- checked state is removedifToggled
- input's checked state is changedifDisabled
-input's state is changed to disabledifEnabled
- disabled state is removedifIndeterminate
- input's state is changed to indeterminateifDeterminate
- indeterminate state is removedifCreatedinput
- is just customizedifDestroyed
- customization is just removedJSFIDDLE
Avoid using jquery as much as you can. You can also use code below;
$('input').on('ifChecked', function(event){
alert(event.target.value); // alert value
});
$('body').on('ifChecked','.icheck', function(){
//considering icheck is the class of your checkbox and it is getting generated dynamically
});
Use this
// Check #x
$( "#x" ).prop( "checked", true );
// Uncheck #x
$( "#x" ).prop( "checked", false );