Q:

Using jQuery display the checked attribute and property of a checkbox as it changes

0

Using jQuery display the checked attribute and property of a checkbox as it changes.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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();

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now