Get the App
SLTechnology News&Howtos  ›  Development  › 

How jquery adds disable attributes to elements

Shulou Source: shulou.com Published: 2022-06-02 13:22:59 10月03日 Update

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!

Tags: Elements attributes methods learning more help practical next tutorials articles versions environment theory computers knowledge examples articles systems websites grammar Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn NVidia MySQL Docker Microsoft