Using jQuery display the checked attribute and property of a checkbox as it changes.
HTML Code :
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-git.js"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Using jQuery display the checked attribute and property of a checkbox as it changes.</title> </head> <body> <input id="check1" type="checkbox" checked="checked"> <label for="check1">Check me</label> </body> </html>
JavaScript Code :
$( "input" ) .change(function() { var $input = $( this ); console.log(".attr( 'checked' )"); console.log(".prop( 'checked' ): " +$input.prop( "checked" )) ; console.log(".is( ':checked' ): " + $input.is( ":checked" ) ); }) .change();
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
HTML Code :
JavaScript Code :