Javascript 如何使用Twitter引导在按钮点击上导航到另一个页面?

Javascript 如何使用Twitter引导在按钮点击上导航到另一个页面?,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,我必须呈现驻留在模板/home.html 我在index.html中有一个按钮: <div id="browse_app"> <button class="btn btn-large btn-info" type="button">Browse</button> </div> // onClick on 'Browse' load the internal page $(function(){ $('#browse_app').c

我必须呈现驻留在
模板/home.html

我在
index.html
中有一个按钮:

<div id="browse_app">
    <button class="btn btn-large btn-info" type="button">Browse</button>
</div>
// onClick on 'Browse' load the internal page
$(function(){
    $('#browse_app').click(function(){
        $.load('templates/home.html');
    });
});
但这不起作用,因为load需要将数据放在当前页面的某个位置

如何在单击按钮时访问
home.html

使用以下方法:

$(function(){
    $('#browse_app').click(function(){
        window.location='templates/home.html'
    });
});

据我所知,你正在使用。该文档阐述了您的观点:

默认按钮

按钮样式可以应用于应用了
.btn
类的任何对象。但是,通常您只希望将这些应用于

在最坏的情况下,这样按钮的渲染看起来不好,但链接可以工作。使用JS,最坏的情况将使链接无效。

使用:
onclick=“window.location=”
在按钮标记中插入HTML文件

我之前准备的一个:
«;关于HerdMASTER 4

我想转到同一文件夹中的目录,从另一个目录中学习

这是一个更优雅的解决方案,它使用了包含的引导类,这意味着您不必在页面中插入代码。我希望有更多关于各种引导类的功能文档,因为我从上面的代码中了解到了这一点,而不是通过谷歌搜索找到它。

使用onclick=“window.open('YourPage.aspx','u self');”

例如:

<button type="submit" onclick="window.open('YourPage.aspx','_self');" class="btn btn-default">Your Page</button>
您的页面

为什么不使用
?如果您使用的是Bootstrap,您可以使用相同的CSS类将其样式设置为按钮。您使用的是Twitter Bootstrap,对吗?@daydreamer,不要忘记我还需要将
role=“button”
添加到
标记中,以正确显示字体颜色(Bootstrap 4.3.1)。
<button type="submit" onclick="window.open('YourPage.aspx','_self');" class="btn btn-default">Your Page</button>