IE9下解决disable不能脱离焦点问题
又一个月没来了,真是忙坏了。~ 记录下最近项目中遇到的问题,防备以后再次遇到,也方便同遇到的人吧~
//View Code <input id="txtProjectManager" name="txtProjectManager" type="text" value="" maxlength="100" style="width: 130px;" disabled=disabled/>
Js代码
//处理IE9 disable焦点无法移除bug Created by Isaac start function addDivForDisableControl(selector) { selector.wrap("<div onmousedown='return false;' onmousemove='return false;' style='display: inline'></div>"); } function removeDivForDisableControl(selector) { selector.unwrap(); } //调用方式 $(window).load(function () { addDivForDisableControl($('[disabled=disabled]')); });
解决思路,因为是ie9本身的bug,我们只能通过遮罩层来不允许其获得焦点,就OK了,当然取值的时候,要注意移除遮罩层哦~~
在编程的道路上,一往无前,埋头狂奔。
[奔跑的人生] | [segmentfault] | [spring4all] | [csdn] | [掘金] | [OSChina] | [简书] | [知乎] | [51CTO]
[奔跑的人生] | [segmentfault] | [spring4all] | [csdn] | [掘金] | [OSChina] | [简书] | [知乎] | [51CTO]