jquery禁用a标签,jquery禁用按钮click点击
发布时间:2017-09-29, 17:50:31 分类:HTML | 编辑 off 网址 | 辅助
正文 1105字数 283,865阅读
jq 禁止a跳转jquery禁用a标签方法1
$(document).ready(function () {
$("a").each(function () {
var textValue = $(this).html();
if (textValue == "XX概况" || textValue == "服务导航") {
$(this).css("cursor", "default");
$(this).attr('href', '#'); //修改<a>的 href属性值为 # 这样状态栏不会显示链接地址
$(this).click(function (event) {
event.preventDefault(); // 如果<a>定义了 target="_blank“ 需要这句来阻止打开新页面
});
}
});
});
Run code
Cut to clipboard
jquery禁用a标签方法2
$('a.tooltip').live('click', function(event) {
alert("抱歉,已停用!");
event.preventDefault();
});
Run code
Cut to clipboard
jquery禁用a标签方法3
$(function(){
$('.disableCss').removeAttr('href');//去掉a标签中的href属性
$('.disableCss').removeAttr('onclick');//去掉a标签中的onclick事件
});
Run code
Cut to clipboard
jquery控制按钮的禁用与启用
控制按钮为禁用:
控制按钮为禁用:
$('#button').attr('disabled',"true");添加disabled属性
$('#button').removeAttr("disabled"); 移除disabled属性
Run code
Cut to clipboard
(支付宝)给作者钱财以资鼓励 (微信)→
有过 1 条评论 »
取消事件的默认动作。
在 touchend 中解除 touchmove 绑定
$("#id").on(' touchstart',function(){ $("#id").on('touchmove',function(event) { event.preventDefault(); }, false);})$("#id").on(' touchend',function(){ $("#id").unbind('touchmove');})
用
$("body").bind("touchmove",function(event){event.preventDefault;//code});
取消了body的拖动事件。
恢复这个拖动事件只要
$("body").unbind("touchmove");