禁用输入上的OnClick事件

Hyd*_*gen 5 html javascript html5 javascript-events

  • 我需要onclick<input>禁用的标签上有一个事件.
  • 这里的onclick活动不起作用.
  • 有没有其他方法可以使用onclick基于id的禁用输入事件?
  • 我试过下面的代码.
  • 第一次input工作,但我需要像第二次一样工作.(我需要调用功能Clickedinput只).
  • 提前致谢..

我的代码:

function Clicked(event)
{
  alert(event.id)
}
function ClickedDisabled(event)
{
  alert(event.ids)
}
Run Code Online (Sandbox Code Playgroud)
<input type="text" id="ID" onclick="Clicked(this)" />
<input type="text" id="IDs" onclick="ClickedDisabled(this)" disabled />
Run Code Online (Sandbox Code Playgroud)

pri*_*786 5

function Clicked(event) {
  alert(event.id)
}

function ClickedDisabled(event) {
  alert(event.id)
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<input type="text" id="ID" onclick="Clicked(this)" />
<span style="position:relative;">
<input type="text" id="IDs" disabled />
<div style="position:absolute; left:0; right:0; top:0; bottom:0; cursor: pointer;" id="IDs" onclick="ClickedDisabled(this)"></div>
  </span>
Run Code Online (Sandbox Code Playgroud)

试试这个它可能会帮助你