使用onclick禁用文本输入 [英] Disabled Text Input with onclick

查看:83
本文介绍了使用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

推荐答案

如何将事件委托给此处的父元素?

<span style="position:relative;" onClick="event.target.value='clicked';">
  <input type="text" disabled "/>
</span>

如果我的回答可以接受,请对其进行评论,然后我将做出解释.

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

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