Jquery batch set properties readonly and disabled methods
- 2020-03-30 01:29:07
- OfStack
Jquery's API provides methods for applying the disabled and readonly attributes to elements, which are documented here. As follows:
1. The readonly
2. The disabled
There are two other ways to set and remove the disabled property for an element:
1. The readonly
$('input').attr("readonly","readonly")//Set the input element to readonly
$('input').removeAttr("readonly");//Remove the readonly attribute from the input element
if($('input').attr("readonly")==true)//Determines whether the readonly attribute has been set on the input element
For setting for the element readonly Properties and cancellations readonly There are two other methods for attributes:
$('input').attr("readonly",true)//Set the input element to readonly
$('input').attr("readonly",false)//Remove the readonly attribute from the input element
$('input').attr("readonly","readonly")//Set the input element to readonly
$('input').attr("readonly","")//Remove the readonly attribute from the input element
2. The disabled
$('input').attr("disabled","disabled")//Set the input element to disabled
$('input').removeAttr("disabled");//Removes the disabled attribute from the input element
if($('input').attr("disabled")==true)//Determines whether the input element has the disabled property set
There are two other ways to set and remove the disabled property for an element:
$('input').attr("disabled",true)//Set the input element to disabled
$('input').attr("disabled",false)//Removes the disabled attribute from the input element
$('input').attr("disabled","disabled")//Set the input element to disabled
$('input').attr("disabled","")//Removes the disabled attribute from the input element