jQuery禁用a标签链接功能【转】
$(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“ 需要这句来阻止打开新页面 }); } }); });
原文:http://www.cnblogs.com/gb2013/archive/2012/06/21/2557287.html
🐳 作者:dupeng0811 📢 版权:本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接 💬 留言:同时 , 如果文中有什么错误,欢迎指出。以免更多的人被误导。 |
|