Pawan
Pawan

Reputation: 32321

How to get text field disabled property

I have a div as shown below. How to know if the location id is disabled or not ??

<div class="stTime fields">
    <input id="location" type="text" placeholder="Label (Example Office , Home) " disabled="">
</div>

I have tried this way

var prop = $("#location").prop();

but i am getting Uncaught TypeError: Cannot read property 'nodeType' of undefined in console

Upvotes: 1

Views: 88

Answers (2)

collab-with-tushar-raj
collab-with-tushar-raj

Reputation: 1287

If you are using older versions of jQuery

  var prop = $("#location").attr('disabled');

As of jQuery 1.6 , .prop() has been introduced

  var prop = $("#location").prop('disabled');

Upvotes: -1

Pratik Joshi
Pratik Joshi

Reputation: 11693

jsFiddle Demo

var prop = $("#location").prop("disabled");
alert(prop)

Upvotes: 2

Related Questions