jquery禁用a標籤,jquery禁用按鈕click點擊

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“ 需要這句來阻止打開新頁面
                });
            }
        });
});

jquery禁用a標籤方法2

$('a.tooltip').live('click', function(event) {
   alert("抱歉,已停用!");  
  event.preventDefault();   
});

jquery禁用a標籤方法3

$(function(){
$('.disableCss').removeAttr('href');//去掉a標籤中的href屬性
$('.disableCss').removeAttr('onclick');//去掉a標籤中的onclick事件
});

jquery控制按鈕,input的禁用與啓用

$('#button').attr('disabled',"true");添加disabled屬性 
$('#button').removeAttr("disabled"); 移除disabled屬性





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章