iCheck library: value of selected radio button
Try this out:- http://jsfiddle.net/adiioo7/yhmu97qh/
JS:-
$(document).ready(function () {
$('input').iCheck({
radioClass: 'iradio_flat-orange'
});
$('input').on('ifClicked', function (event) {
var value = $(this).val();
alert("You clicked " + value);
});
});
I found the other answers to be useful. However, they are dependent on iCheck's 'ifClicked'. You may not want the value to pop up every time a new radio button is selected, but instead only when a user hits a specific button calling for the alert and corresponding value.
For example:
$(document).on('click', '.buttonClass', function(event) {
return alert($('.radioClass:checked').val());
});
Just another hacky way to get checked value with jQuery selectors:
$(".checked input[name=name-of-original-input]").val();
But AFAIK default class for checked values could be changed in configuration.
BTW, I think that iCheck isn't a good choice if it creates such issues with very simple functionality.
You must use iCheck like this
$(document).ready(function () {
$('input[name="iCheck"]').on('ifClicked', function (event) {
alert("You clicked " + this.value);
});
$('input').iCheck({
radioClass: 'iradio_flat-orange'
});
});
DEMO
Documentation