
在jquery中,可以利用removeAttr()方法来移除元素的readonly属性,该方法可以从被选元素中移除指定属性,语法“$(selector).removeAttr("readonly")”。
本教程 *** 作环境:windows7系统、jquery1.10.2版本、Dell G3电脑。
readonly 属性规定输入字段为只读。只读字段是不能修改的。不过,用户仍然可以使用 tab 键切换到该字段,还可以选中或拷贝其文本。
readonly 属性可以防止用户对值进行修改,直到满足某些条件为止(比如选中了一个复选框)。
jquery移除readonly(只读)效果
在jquery中,可以利用removeAttr()方法来移除元素的readonly属性
removeAttr() 方法用于从被选元素中移除属性。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("button").click(function() {
$("textarea").removeAttr("readonly");
});
});
</script>
</head>
<body>
<textarea readonly="readonly">测试文本</textarea><br><br>
<button>移除readonly(只读)效果</button>
</body>
</html>【推荐学习:jQuery视频教程、web前端开发视频】
以上就是jquery怎么移除readonly属性的详细内容,
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)