Double click javascript permission insert

I have a form with some inputs disabled. I want these inputs to be turned on with a double click. Unfortunately, JS events don't seem to fire when inputs are disabled.

<input type="text" value="asdf" disabled="disabled" ondblclick="this.disabled=false;">โ€‹ 

Is there any way to limit this restriction?

Or will I just have to wrap any affected input in the gap to accommodate the event?

http://jsfiddle.net/vhktx/

+6
source share
2 answers

ondblclick does not start in the disabled element, you should mark it as readonly :

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

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

+11
source

You will have to wrap the item in a container, as the event will not fire when the items are disabled.

jsFiddle

 <div ondblclick="document.getElementById('test').disabled=false;"> <input type="text" id="test" value="asdf" disabled="disabled"></div> 
+4
source

Source: https://habr.com/ru/post/919638/


All Articles