jquery设置input不可编辑,背景变灰,鼠标变禁止


先看效果

 

$("#id").attr("onfocus", "this.blur()");
$("#id").css("background", "#CCCCCC");
$("#id").css("cursor", "not-allowed");

 

不可编辑有三个方法

第一种是onfocus=this.blur(),这种比下面两种好,因为连文字也不能选择

$("#newNoteName").attr("onfocus", "this.blur()");

 

第二种是disabled="disabled"

$("#id").attr("disabled", "disabled");

 

第三种是readonly或者是readonly=“true”

$("#id").attr("readonly", "true");

 

参考文章:https://blog.csdn.net/delongcpp/article/details/8171826


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM