代码如下:
 
复制代码 代码示例:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>
jquery禁用a和input 打开链接页面_www.jb200.com</title>  
<script type="text/
javascript" src="jquery-1.4.2.min.js"></script>  
<script type="text/javascript">  
$(document).ready(function(){  
  $("a").attr('href','#');     //修改<a>的 href属性值为 #  这样状态栏不会显示链接地址  
  $("a").click(function(event){  
     event.preventDefault();   // 如果<a>定义了 target="_blank“ 需要这句来阻止打开新页面  
      alert("抱歉!此项目已停用!");  
});  
$("input").attr('onclick',''); //修改<input>的onclick事件为空  
$("input").click(function(){  
 alert("抱歉!此项目已停用!");  
});  
});  
</script>  
</head>  
<body>  
<a href="http://www.jbxue.net" target="_blank">jbxue.net</a>  
<a href="http://www.jbxue.cn" target="_blank">jbxue.cn</a>  
<input type="button" value="click" onclick="javascript:window.open('http://www.jb200.com','_blanks')" />  
</body>  
</html>
当然,如果整个页面里希望有某一个链接可以打开,如<a href="" id="butme"></a>,可以:
 
$("a").not("#butme").attr('href','#');
$("a").not("#butme")click(function(){.....});
多个则使用class。
附1,jQuery去掉A链接虚线框
 
$("a").bind("focus",function(){if(this.blur)this.blur();});
附2,jQuery禁用a标签链接功能
在页头中添加如下脚本块即可:
 
复制代码 代码示例:
$(document).ready(function () {
   $("a").each(function () {
   var textValue = http://www.jb200.com/article/$(this).html();
   if (textValue =http://www.jb200.com/article/= "XX概况" || textValue =http://www.jb200.com/article/= "服务导航") {
   $(this).css("cursor", "default");
   $(this).attr('href', '#');     //修改<a>的 href属性值为 #  状态栏将不会显示链接地址  
   $(this).click(function (event) {
      event.preventDefault();   // 如果<a>定义了 target="_blank“,需要这句用于阻止打开新页面
  });
}
 });
});