【问题标题】:How can events be enabled for a disabled input?如何为禁用的输入启用事件?
【发布时间】:2014-09-17 22:15:30
【问题描述】:

These solutions(复制在下面)不起作用,因为输入的value 是预设的,需要水平滚动..绝对定位的 div 覆盖输入并阻止它滚动..

<span style="position:relative;">
  <input type="text" disabled />
  <div id="textInput" style="position:absolute; left:0; right:0; top:0; bottom:0; cursor: pointer;" ></div>
</span>
document.getElementById("textInput").onclick = function() {
    alert("Input clicked");
}

在保持输入滚动的同时启用事件有什么建议吗?

【问题讨论】:

    标签: css input disabled-input


    【解决方案1】:

    设为readonly 而不是disabled

    【讨论】:

    • 有什么建议可以防止光标出现吗?这会是 CSS 吗?
    • 是的,cursor: none 应该这样做。
    • 啊,这实际上是问题所在:stackoverflow.com/questions/7917592/… .. 谢谢你的提示,只读功能真的很完美
    猜你喜欢
    • 1970-01-01
    • 2011-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-26
    相关资源
    最近更新 更多