美文网首页
只读状态设置 css

只读状态设置 css

作者: jeneen1129 | 来源:发表于2022-11-03 18:34 被阅读0次

想要能够显示 只读状态,由于一些原因无法移除点击事件,就控制 pointer-eventscursor(https://developer.mozilla.org/zh-CN/docs/Web/CSS/cursor
) 属性来完成。然后再加上其他样式。

// 设置点击事件不可用
$("#verificode").css(“pointer-events”, “none”);
$("#verificode").css(“cursor”, “not-allowed”); // text
// 点击事件可用
$("#verificode").css(“pointer-events”, “auto”);

var redone=document.getElementById("gd2_3");
redone.addEventListener('click',canbeclick,true);
function canbeclick(){
    alert("啊,好冷啊!");        
}
redone.removeEventListener('click',canbeclick,true);
// 针对html标签内的onclick用document.getElenmentById(“id”).οnclick=null;是有效的。

相关文章

网友评论

      本文标题:只读状态设置 css

      本文链接:https://www.haomeiwen.com/subject/hxzkortx.html