现在的位置: 首页 > 综合 > 正文

jQuery禁用a标签链接功能【转】

2012年12月31日 ⁄ 综合 ⁄ 共 372字 ⁄ 字号 评论关闭
$(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

抱歉!评论已关闭.