双击javascript启用输入 [英] javascript enable input on double click

查看:111
本文介绍了双击javascript启用输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些禁用某些输入的表单。我希望这些输入在双击时启用。不幸的是,JS事件似乎不会禁用已禁用的输入。

 < input type =textvalue =asdf已禁用=disabledondblclick =this.disabled = false;> 

有没有办法在这个限制之下?



或者我只是需要在一个范围内包装任何受影响的输入以容纳该事件?



http://jsfiddle.net/vhktx/

c> ondblclick 不会在禁用元素上触发,您应该标记它 readonly

 < input type =textvalue = asdfreadonly =trueondblclick =this.readOnly ='';> 

http: //jsfiddle.net/vhktx/4/


I have a form with some inputs disabled. I want these inputs to be enabled when double clicked. Unfortunately, JS events seem not to fire on disabled inputs.

<input type="text" value="asdf" disabled="disabled" ondblclick="this.disabled=false;">​

Is there a way around this limitation?

Or am I just going to have to wrap any affected input in a span to house the event?

http://jsfiddle.net/vhktx/

解决方案

ondblclick does not get fired on a disabled element, you should mark it as readonly:

<input type="text" value="asdf" readonly="true" ondblclick="this.readOnly='';">

http://jsfiddle.net/vhktx/4/

这篇关于双击javascript启用输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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