Both .attr('disabled', 'disabled')
and .attr('disabled', true)
work in my code, but I'm just wondering: which among the two is more efficient and/or which is more used? Is there really a difference? Performance-wise, maybe?
The Boolean disabled attribute, when present, makes the element not mutable, focusable, or even submitted with the form. The user can neither edit nor focus on the control, nor its form control descendants.
Projects In JavaScript & JQuery To remove disabled attribute using jQuery, use the removeAttr() method. You need to first remove the property using the prop() method. It will set the underlying Boolean value to false.
The disabled attribute can be set to keep a user from using the element until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the element usable again.
Definition and Usage The disabled attribute is a boolean attribute. When present, it specifies that the <input> element should be disabled. A disabled input element is unusable and un-clickable.
HTML <input> disabled Attribute 1 Definition and Usage. The disabled attribute is a boolean attribute. When present, it specifies that the <input> element... 2 Browser Support. The numbers in the table specify the first browser version that fully supports the attribute. 3 Syntax. More ...
This attr () function is first applied to the element which is input element or input field or input box then it is followed by the dot operator along with attr () function in which there are two parameters passed to this function and both the parameters are declared as “disabled” this is done when we are disabling the matched or specified element.
If the disabled attribute is specified on a form control, the element and its form control descendants do not participate in constraint validation. Often browsers grey out such controls and it won't receive any browsing events, like mouse clicks or focus-related ones.
Should not make any difference. But from jQuery 1.6+ you should use:
$('input').prop('disabled', true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With