使用引导程序向导航栏添加外部链接 [英] Adding an external link to a nav bar using bootstrap

查看:38
本文介绍了使用引导程序向导航栏添加外部链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用引导程序在导航栏中包含外部链接?当我将菜单项文本包装在一个链接标签中时,该链接不起作用......我错过了什么吗?具体来说,我想添加一个指向导航菜单的外部链接,其中其他项目仅链接到页面上的区域.

Is it possible to include an external link in a nav bar utilizing bootstrap? When I wrap the Menu item text in an a link tag, the link doesn't work...am I missing something? Specifically, I would like to add an external link to a navigation menu in which the other items just link to areas on the page.

推荐答案

我遇到了同样的问题;我只是使用 JQuery 重定向到外部链接,如下所示:

I had the same problem; I just redirect to external link with JQuery as follows:

HTML:

<ul class="nav">
    <li><a href="http://www.google.com" class="external">External</a></li>
    <li>...</li>
</ul>

JQuery:

function changePage(event) {
    if($(event.target).hasClass('external')) {
        window.location.href = $(event.target).attr('href');
        return;
    }
    //...
}
$(function () {
    $('.nav li').click( changePage );
}

这篇关于使用引导程序向导航栏添加外部链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆