Alosyius
Alosyius

Reputation: 9121

Disable textarea without jQuery?

How would i disable a textarea without using jQuery?

Am using the following at the moment:

$("#textareaId").attr("disabled", "disabled");

Upvotes: 0

Views: 106

Answers (3)

DevelopmentIsMyPassion
DevelopmentIsMyPassion

Reputation: 3591

Try below

document.getElementById("mytxt").disabled=true;

Link to fiddle here

Upvotes: 0

Justin John
Justin John

Reputation: 9616

Try with setAttribute method and check any difference in output.

document.getElementById("textareaId").setAttribute('disabled', true);

Upvotes: 0

Denys Séguret
Denys Séguret

Reputation: 382150

Simply do

document.getElementById("textareaId").disabled=true;

Demonstration

jQuery is a JavaScript library, everything you do using it can be done in JavaScript, even if it's often a little more verbose or implies a greater care to browser differences. See http://vanilla-js.com/

Upvotes: 4

Related Questions