Reputation: 35542
I am trying to bulk disable all the submit buttons present in my form. I am getting all the buttons using the following jQuery
jQuery('input')
This returns me an array of the Input tags. I can iterate through this and disable each and every one of them. But is there a better way to perform this operation. Something like,
jQuery('input').disable()
Upvotes: 2
Views: 83
Reputation: 103525
There is no intrinsic disable
function. In the book "Jquery In Action", they created enable
and disable
methods for the example on how to create a jQuery plugin, so I've just kept those and used them.
Upvotes: 0
Reputation: 324597
You can do it efficiently and easily without jQuery:
var inputs = document.body.getElementsByTagName("input");
for (var i = 0, len = inputs.length; i < len; ++i) {
if (input.type == "submit") {
inputs[i].disabled = true;
}
}
Upvotes: 2