twitter-bootstrap Bootstrap 按钮链接不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21332732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 19:49:56  来源:igfitidea点击:

Bootstrap Button Link Not Working

javascripthtmltwitter-bootstrap

提问by user3231982

Bootstrap Button Link Not Working see code below:

Bootstrap 按钮链接不起作用,请参阅以下代码:

<ul>
  <li>
      <a href="home.aspx?Id=146">
            <button class="btn btn-primary btn">Button Link</button>             
      </a>
 </li>
</ul>

I use firebug for development, is there an easy place to see what javascript events are attached and to which objects such as this button class? find it hard to debug as don't know what code is being called and on what events for bootstrap and other external js files

我使用 firebug 进行开发,是否有一个简单的地方可以查看附加了哪些 javascript 事件以及哪些对象(例如此按钮类)?发现很难调试,因为不知道正在调用什么代码以及引导程序和其他外部 js 文件的事件

回答by Zim

Or, you can just use a link which looks like a button..

或者,您可以只使用看起来像按钮的链接。

<a href="home.aspx?Id=146" class="btn btn-primary">Button Link</a>

回答by zzlalani

Remove atag and add window.location.hrefto button onclick

删除a标签并添加window.location.href到按钮onclick

<button class="btn btn-primary btn" 
        onclick="window.location.href='home.aspx?Id=146'; return false;">
        Button Link
</button>