双击javascript启用输入 [英] javascript enable input on double click
本文介绍了双击javascript启用输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些禁用某些输入的表单。我希望这些输入在双击时启用。不幸的是,JS事件似乎不会禁用已禁用的输入。
< input type =textvalue =asdf已禁用=disabledondblclick =this.disabled = false;>
有没有办法在这个限制之下?
或者我只是需要在一个范围内包装任何受影响的输入以容纳该事件?
禁用
元素上触发,您应该标记它 readonly
: < input type =textvalue = asdfreadonly =trueondblclick =this.readOnly ='';>
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?
解决方案
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='';">
这篇关于双击javascript启用输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文