JSFiddle - React, Tailwind, and code Playground

by Timmy Willison

HTML

<script src="http://getfirebug.com/firebug-lite-debug.js"></script>
<script src="http://timmywillison.com/jquery/attrhooks/jquery.js"></script>
<div id="container">
  <input type="checkbox" id="foo" />
</div>

JavaScript

$(function() {
    var obj = $("<input />").attr('type', 'checkbox');
    obj.attr("checked", true);
    
    console.log(obj.attr('checked'));
    console.log(obj[0].checked);
    console.log(obj[0].getAttribute('checked'));
    
    obj.appendTo('#container');
    
    console.log(obj.attr('checked'));
});