Home > Article > Web Front-end > How to control a tag to be non-clickable in jquery
Jquery method to control the a tag not being clickable: 1. Remove the href attribute in the a tag, the code is [$('.disableCss').removeAttr('href')]; 2. Add the disabled attribute, The code is [attr('disabled',"true")].
jquery method to control a tag not clickable:
jquery disable a tag method 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“ 需要这句来阻止打开新页面 }); } }); });
jquery disable a tag method 2
$('a.tooltip').live('click', function(event) { alert("抱歉,已停用!"); event.preventDefault(); });
jquery disable a tag method 3
$(function(){ $('.disableCss').removeAttr('href');//去掉a标签中的href属性 $('.disableCss').removeAttr('onclick');//去掉a标签中的onclick事件 });
jquery Disabling and enabling control buttons
The control button is disabled:
$('#button').attr('disabled',"true");添加disabled属性 $('#button').removeAttr("disabled"); 移除disabled属性
Related free learning recommendations:JavaScript(video)
The above is the detailed content of How to control a tag to be non-clickable in jquery. For more information, please follow other related articles on the PHP Chinese website!