本文摘自PHP中文网,作者青灯夜游,侵删。

推荐教程:jq教程
jquery设置元素的readonly和disabled
1.readonly
1 2 3 4 | $( 'input' ).attr( "readonly" , "readonly" )
$( 'input' ).removeAttr( "readonly" );
if ($( 'input' ).attr( "readonly" )== true )
|
对于为元素设置readonly属性和取消readonly属性的方法还有如下两种:
1 2 | $( 'input' ).attr( "readonly" , true )
$( 'input' ).attr( "readonly" , false )
|
1 2 | $( 'input' ).attr( "readonly" , "readonly" )
$( 'input' ).attr( "readonly" , "" )
|
2.disabled
1 2 3 4 | $( 'input' ).attr( "disabled" , "disabled" )
$( 'input' ).removeAttr( "disabled" );
if ($( 'input' ).attr( "disabled" )== true )
|
对于为元素设置disabled属性和取消disabled属性的方法还有如下两种:
1 2 | $( 'input' ).attr( "disabled" , true )
$( 'input' ).attr( "disabled" , false )
|
1 2 | $( 'input' ).attr( "disabled" , "disabled" )
$( 'input' ).attr( "disabled" , "" )
|
更多编程相关知识,请访问:编程视频!!
以上就是jquery给元素设置/取消readonly和disabled属性的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
jQuery 如何判断是否有div
jQuery的easyui和layui区别是什么
jQuery表示什么?
jQuery怎么给div赋值
jQuery怎么替换html内容
jQuery easyui 乱码怎么办
jQuery如何判断元素是否在数组中
jQuery如何判断鼠标是否在元素上
jQuery如何判断数组包含指定元素
jQuery怎样创建元素节点
更多相关阅读请进入《jQuery》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » jquery给元素设置/取消readonly和disabled属性