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

  • جي كويري

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();
هل كان المحتوى مفيد؟

القوائم الدراسية التي ينتمي لها السؤال

معلومات ذات صلة

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...