JSFiddle - React, Tailwind, and code Playground

by jitter

HTML

<button id="clickme" onclick="tellme()"> How many disabled inputs are on this page? </button> 
<div id="cont">
    <input type="text" value="input1" disabled="disabled" />
</div>

JavaScript

var div = document.getElementById("cont"),
    inp = document.createElement( "input" );

inp.type = "text";
inp.value = "input2";
inp.disabled = "disabled";
div.appendChild( inp );

var docf = document.createDocumentFragment(),
    ndiv = document.createElement( "div" );

ndiv.innerHTML = '<input type="text" value="input1" disabled="disabled" />';
docf.appendChild( ndiv.firstChild );
div.appendChild( docf.firstChild );


function tellme() {
    alert( div.querySelectorAll(":disabled").length );
}