js实现禁用,鼠标不可点击

本文所讲的禁用针对的是没有disable属性的元素,如div、li标签等,有该属性的元素如input、button标签等需要禁用可直接对此属性进行设置。

鼠标不可点击主要是两种表现:

1.鼠标不可点击时的显示状态

//document.getElementById('id').style.color="grey";(置灰)
//$('#id').style.color="grey";(置灰)
cursor: not-allowed;

document.getElementById('id').style.cursor="not-allowed";

2.鼠标原有的事件不能实现

pointer-events:none;

.notclick {
    pointer-events: none; 
}
//$("#id").addClass("notclick");

//$(".原类名").addClass("新类名");  
$(".click").addClass("notclick");

 


版权声明:本文为qq_39052833原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。