最新jQuery移除或禁用html元素的诠释过程

移除或禁用html元素的点击事件可以通过css实现也可以通过js或jQuery实现。

一、CSS方法
.disabled { pointer-events: none; }

二、jQuery方法
方法一

$(this).click(function (event) {
event.preventDefault();
}

方法二
$(‘a’).live(‘click’, function(event) {
alert(“抱歉,已停用!”);
event.preventDefault();
});

注:此方法中的live亦可以为on,bind等方法

方法三

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

通过removeAttr方法来控制html标签的属性已达到启用或禁用事件。另,使用这种方式也可以控制其他事件或其他效果。

方法四

$(’#button’).attr(‘disabled’,“true”);//添加disabled属性
$(’#button’).removeAttr(“disabled”); //移除disabled属性

注:和方法三是一样的,不过disabled属性一般用在类型为button或submit的input上
下面为大家提供链接代码

http://www.abbao.cn/SearchPaper.aspx?paperName=%E6%9E%9C%E5%8D%9A%E4%B8%9C%E6%96%B9_18183615678
http://www.infzm.com/search?k=%E6%9E%9C%E5%8D%9A%E4%B8%9C%E6%96%B9_18183615678
http://so.wenweipo.com/search.php?q=%AAG%B3%D5%26%2319996%3B%A4%E8_18183615678&artype=0&inputencode=BIG-5
http://search.takungpao.com/?q=%E6%9E%9C%E5%8D%9A%E4%B8%9C%E6%96%B9_18183615678
http://so.dbw.cn/search.html?q=%E6%9E%9C%E5%8D%9A%E4%B8%9C%E6%96%B9_18183615678
http://bbs1.people.com.cn/quickSearch.do?field=title&threadtype=1&content=%E6%9E%9C%E5%8D%9A%E4%B8%9C%E6%96%B9_18183615678
https://search.sohu.com/?keyword=%E6%9E%9C%E5%8D%9A%E4%B8%9C%E6%96%B9_18183615678&spm=smpc.csrpage.0.0.1590816261760yAs9GBQ&queryType=outside
http://www.sina.com.cn/mid/search.shtml?range=all&c=news&q=%E6%9E%9C%E5%8D%9A%E4%B8%9C%E6%96%B9_18183615678&from=home&ie=utf-8
http://ts.21cn.com/home/search?keyword=%E6%9E%9C%E5%8D%9A%E4%B8%9C%E6%96%B918183615678

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值