
jquery让a不跳转的方法:
1、jquery中可以通过attr()方法设置a标签中的href属性为“#”来使a标签不跳转
$(document).ready(function () {
$("a").each(function () {
var textValue = $(this).html();
if (textValue == "XX概况" || textValue == "服务导航") {
//修改<a>的 href属性值为 # 这样状态栏不会显示链接地址
$(this).css("cursor", "default");
$(this).attr('href', '#');
$(this).click(function (event) {
// 如果<a>定义了 target="_blank“ 需要这句来阻止打开新页面
event.preventDefault();
});
}
});
});2、jquery通过去除a标签的点击事件让a标签不跳转
$('a.tooltip').live('click', function(event) {
alert("抱歉,已停用!");
event.preventDefault();
});更多相关知识请关注前端学习网站
以上就是jquery怎么让a标签不跳转?的详细内容,更多请关注易知道|edz.cc其它相关文章!










