如何将“只读”属性添加到< input>? [英] How to add a “readonly” attribute to an <input>?

查看:91
本文介绍了如何将“只读”属性添加到< input>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 readonly 添加到特定< input> .attr('readonly')不起作用。

How can I add readonly to a specific <input>? .attr('readonly') does not work.

推荐答案

jQuery < 1.9

jQuery <1.9

$('#inputId').attr('readonly', true);

jQuery 1.9 +

jQuery 1.9+

$('#inputId').prop('readonly', true);

了解更多关于 prop和attr之间的区别

这篇关于如何将“只读”属性添加到&lt; input&gt;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆