jquery sets/cancels readonly and disabled attributes for elements

青灯夜游
Release: 2021-01-22 09:49:33
forward
3358 people have browsed it

jquery sets/cancels readonly and disabled attributes for elements

Recommended tutorial:jq tutorial

jquery sets readonly and disabled of elements

1.readonly

$('input').attr("readonly","readonly")//将input元素设置为readonly $('input').removeAttr("readonly");//去除input元素的readonly属性 if($('input').attr("readonly")==true)//判断input元素是否已经设置了readonly属性
Copy after login

There are two other ways to set the readonly attribute and cancel the readonly attribute for an element as follows:

$('input').attr("readonly",true)//将input元素设置为readonly $('input').attr("readonly",false)//去除input元素的readonly属性
Copy after login
$('input').attr("readonly","readonly")//将input元素设置为readonly $('input').attr("readonly","")//去除input元素的readonly属性
Copy after login

2.disabled

$('input').attr("disabled","disabled")//将input元素设置为disabled $('input').removeAttr("disabled");//去除input元素的disabled属性 if($('input').attr("disabled")==true)//判断input元素是否已经设置了disabled属性
Copy after login

There are two other ways to set the disabled attribute and cancel the disabled attribute for an element:

$('input').attr("disabled",true)//将input元素设置为disabled $('input').attr("disabled",false)//去除input元素的disabled属性
Copy after login
$('input').attr("disabled","disabled")//将input元素设置为disabled $('input').attr("disabled","")//去除input元素的disabled属性
Copy after login

For more programming-related knowledge, please visit:Programming Video! !

The above is the detailed content of jquery sets/cancels readonly and disabled attributes for elements. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!