开发者

Opera - Prevent input from having focus

开发者 https://www.devze.com 2023-03-20 16:03 出处:网络
I have a hidden input on one of my pages, and by hidden, I mean visible, but just looks like plain text.

I have a hidden input on one of my pages, and by hidden, I mean visible, but just looks like plain text.

Take f开发者_运维百科or example http://jsfiddle.net/imoda/nVhp8/

But I don't want a user to be able to click in it and edit the information. Essentially disabling it, but without setting it to disabled in the html. I think I'm close but whatever I've tried isn't working.

Seems to work in everything except Opera. Help please?


Instead of using jQuery, why not simply use the readonly attribute, removing that attribute once the edit button has been clicked?

JS Fiddle.

References:

  • readonly.


Use a timeout..

$("input").focus(function(){
    var _this = this;
    setTimeout(function(){_this.blur();},1);
});

and a more extended example at http://jsfiddle.net/gaby/nVhp8/2/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号