Disabled Text Input with onclick(使用 onclick 禁用文本输入)
问题描述
对于禁用的文本输入,我需要一种捕获 onclick 的方法.我宁愿不使用 jQuery,但如果没有 javascript 替代品,我会使用它.提前致谢
I need a way of capturing onclick, for a text input that is disabled. I would prefer not to use jQuery, but if there was no javascript alternative, would use it. Thanks in advance
我尝试简单地将 onclick="" 添加到禁用的文本字段中,但这不起作用.没有jquery有什么办法吗?谢谢
I have tried simply adding an onclick="" to a disabled text field, which did not work. Is there any way to do it without jquery? Thanks
推荐答案
如何将事件委托给父元素,例如 这里?
How about delegation events to parent elements like here?
<span style="position:relative;" onClick="event.target.value='clicked';">
<input type="text" disabled "/>
</span>
如果我的回答可以接受,请发表评论,我会做出解释.
这篇关于使用 onclick 禁用文本输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!