onDblClick event on a non-editable text box in HTML
I need to perform an action on double click of a text box, but the onDblClick
event does not seem to register when the text box is not edita开发者_如何学JAVAble (i.e. greyed out). Is there something I can do to solve this?
How about applying the onDblClick event to the parent div your text box is in?
e.g.
<div ondblclick="someAction()"><input type="text" readonly="true" /></div>
Apparently ,
The legacy code was using the 'disabled' property of the element to toggle editability of the text box. So that also disables events on the text box.
textElement.disabled = true;
To fix this,
I used the 'readOnly' property of the element for the editability toggling needs and now it registers events.
textElement.readOnly = true;
Thanks for reading!
Rohan.
精彩评论