遇到一个屏蔽点击事件,以前一般都是通过js控制,阻止事件,今天看到css加一个样式就能屏蔽,来记录一下

//css禁用鼠标点击事件

.test { pointer-events: none; }

随便其他方法也记下吧

1.

e.stopPropatation||e.cancelBubble = true

jquery禁用a标签

方法1:

$(document).ready(function() {

$("a").each(function() {

var textValue = $(this).html();

if (textValue == "XX概况" || textValue == "服务导航") {

$(this).css("cursor", "default");

$(this).attr('href', '#');

//修改的 href属性值为 # 这样状态栏不会显示链接地址

$(this).click(function(event) {

event.preventDefault();

// 如果定义了 target="_blank“ 需要这句来阻止打开新页面

});

}

});

});

方法2

$('a.tooltip').live('click', function(event) {

alert("抱歉,已停用!");

event.preventDefault();

});

方法3

$(function() {

$('.disableCss').removeAttr('href'); //去掉a标签中的href属性

$('.disableCss').removeAttr('onclick'); //去掉a标签中的onclick事件

});

直接控制标签禁用

disabled

2026-01-29 01:07:41