Disabled Text Input with onclick

…衆ロ難τιáo~ 提交于 2019-12-01 19:50:43

How about delegation events to parent elements like here?

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

If my answer is acceptable please comment it and I'll make an explanation.

You are probably lookinf for this:-

$("div").click(function (evt) {
    $(this).hide().prev("input[disabled]").prop("disabled", false).focus();
});

DEMO JSFIDDLE

This is the modified jsfiddle proposed by Rahul Tripathi using pure javascript.

This is the function that made it works:

document.getElementById("textInput").onclick = function() {
    alert("Input clicked");
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!