javascripthtmldom-events

OnClick Event on a disabled input


My code:

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


Solution

  • function Clicked(event) {
      alert(event.id)
    }
    
    function ClickedDisabled(event) {
      alert(event.id)
    }
    <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>

    Try this it may help you