利用bootstrap框架實現(xiàn)TODO list的時候垫毙,有個功能是想
禁用a標簽
倡缠,但是利用class="disabled"
發(fā)現(xiàn)不起作用丸卷;
網(wǎng)上查證發(fā)現(xiàn)都說a標簽
沒有這個功能蔚出,也可能是我沒有找到最終的答案汹粤,但是發(fā)現(xiàn)下面的方式是可用的射亏。
Jquery 方法1
$(document).ready(function () {
$("a").each(function () {
var textValue = $(this).html();
if (textValue == "XX概況" || textValue == "服務導航") {
$(this).css("cursor", "default");
$(this).attr('href', '#'); //修改<a>的 href屬性值為 # 這樣狀態(tài)欄不會顯示鏈接地址
$(this).click(function (event) {
event.preventDefault(); // 如果<a>定義了 target="_blank“ 需要這句來阻止打開新頁面
});
}
});
});
Jquery 方法2
$('a.tooltip').live('click', function(event) {
alert("抱歉,已停用近忙!");
event.preventDefault();
});
Jquery 方法3
$(function(){
$('.disableCss').removeAttr('href');//去掉a標簽中的href屬性
$('.disableCss').removeAttr('onclick');//去掉a標簽中的onclick事件
});
Jquery控制按鈕的禁用與啟用
$('#button').attr('disabled',"true");添加disabled屬性
$('#button').removeAttr("disabled"); 移除disabled屬性