How jquery adds disable attributes to elements
This article mainly introduces "how jquery adds disable attributes to elements". In daily operation, I believe many people have doubts about how jquery adds disable attributes to elements. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "jquery how to add disable attributes to elements". Next, please follow the editor to study!
In jquery, you can use the attr () method to add disable attributes to the element, with the syntax "$(selector) .attr (" disabled ", true);" or "$(selector) .attr (" disabled "," disabled ");".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
The disabled attribute states that the element should be disabled. Disabled elements are neither available nor clickable.
Jquery's method of adding disable attributes to elements
The attr () method sets the attribute value of the selected element.
There are two ways to add a disable attribute to an element using the attr () method
$(selector) .attr ("disabled", true); $(selector) .attr ("disabled", "disabled")
Example:
$(document) .ready (function () {$("button") .click (function () {/ / $("input") .attr ("disabled", true); $("input") .attr ("disabled", "disabled") );})
Add disable attribute
At this point, the study on "how jquery adds disable attributes to elements" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!