Home > Web Front-end > JS Tutorial > body text

How to batch set attributes readonly and disabled in jquery_jquery

WBOY
Release: 2016-05-16 17:02:29
Original
1774 people have browsed it

Jquery's API provides methods for applying disabled and readonly attributes to elements, which are recorded here. As follows:
1.readonly

Copy code The code is as follows:

 $('input ').attr("readonly","readonly")//Set the input element to readonly
 $('input').removeAttr("readonly");//Remove the readonly attribute of the input element

  if($('input').attr("readonly")==true)//Determine whether the input element has the readonly attribute set

Methods for setting the readonly attribute and canceling the readonly attribute for the element There are also the following two types:
 $('input').attr("readonly",true)//Set the input element to readonly
 $('input').attr("readonly",false) //Remove the readonly attribute of the input element

$('input').attr("readonly", "readonly") // Set the input element to readonly
$('input').attr ("readonly","")//Remove the readonly attribute of the input element

2.disabled

Copy code The code is as follows:

 $('input').attr("disabled","disabled")//Set the input element to disabled
 $(' input').removeAttr("disabled");//Remove the disabled attribute of the input element

 if($('input').attr("disabled")==true)//Determine whether the input element is The disabled attribute has been set

There are two other ways to set the disabled attribute and cancel the disabled attribute for an element:
Copy code The code is as follows:

 $('input').attr("disabled",true)//Set the input element to disabled
 $('input ').attr("disabled",false)//Remove the disabled attribute of the input element

Copy code The code is as follows:

 $('input').attr("disabled","disabled")//Set the input element to disabled
 $('input').attr( "disabled","")//Remove the disabled attribute of the input element
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template