JSFiddle - React, Tailwind, and code Playground

by Plippie Plop

HTML

<input type="text" disabled="disabled" value="some text">
<br>
<input id="elem2" type="text" disabled="" value="some text">
<br>
<input type="text" disabled="true" value="some text">
<br>
<input type="text" disabled value="some text">
<br>
<input type="text" disabled="BLABLABLA" value="some text">
<br>
<input id="elem4" type="text" value="some text">

JavaScript

$('[type="text"]').each(function (idx) {

    console.log('input:' + idx);


    var attrDisabled = $(this).attr('disabled');

    var propDisabled = $(this).prop('disabled');

    if (attrDisabled !== undefined) {
        console.log('with undefined check: atribute exists = true');
    } else {
        console.log('with undefined check: attribute not exists = false ');
    } 
    
    if (attrDisabled) {
        console.log('atribute exists = true');
    } else {
        console.log('attribute not exists = false ');
    }
    
    
    
     if (propDisabled) {
        console.log('prop exists = true ');
    } else {
        console.log('prop not exists = false ');
    }

    if (propDisabled !==undefined) {
        console.log('with undefined check: prop exists = true ');
    } else {
        console.log('with undefined check: prop not exists = false ');
    }


    console.log('----------------');

});