您的位置:首页 > Web前端 > JQuery

jquery禁用a标签,jquery禁用按钮click点击

2016-09-06 15:49 246 查看
转载自:http://www.wufangbo.com/jquery-jin-yong-a-link/


jquery禁用a标签方法1

01
$(document).ready(
function
 
()
{
02
        
$(
"a"
).each(
function
 
()
{
03
            
var
 
textValue
= $(
this
).html();
04
            
if
 
(textValue
== 
"XX概况"
 
||
textValue == 
"服务导航"
)
{
05
                
$(
this
).css(
"cursor"
"default"
);
06
                
$(
this
).attr(
'href'
'#'
);     
//修改<a>的
href属性值为 #  这样状态栏不会显示链接地址 
07
                
$(
this
).click(
function
 
(event)
{
08
                    
event.preventDefault();   
//
如果<a>定义了 target="_blank“ 需要这句来阻止打开新页面
09
                
});
10
            
}
11
        
});
12
});


jquery禁用a标签方法2

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


jquery禁用a标签方法3

查看源代码

打印帮助

1
$(
function
(){
2
$(
'.disableCss'
).removeAttr(
'href'
);
//去掉a标签中的href属性
3
$(
'.disableCss'
).removeAttr(
'onclick'
);
//去掉a标签中的onclick事件
4
});


jquery控制按钮的禁用与启用

控制按钮为禁用:

1
$(
'#button'
).attr(
'disabled'
,
"true"
);添加disabled属性
2
$(
'#button'
).removeAttr(
"disabled"
);
移除disabled属性
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: