Tuesday, 31 July 2012

Check checkbox checked property using jQuery


Use this code for check box in jquery
if ($('#facebook').is(':checked')) {
    $("#fb").show();
}else {
    $("#fb").hide();
}

You can shorten this using ternary, some might say it's a bit
 less readable, but that's how I would do it:
$('#facebook').is(':checked') ? $("#fb").show() : $("#fb").hide();

No comments:

Post a Comment