如何把一个链接放在一个带有引导的按钮上? [英] How to put a link on a button with bootstrap?

查看:118
本文介绍了如何把一个链接放在一个带有引导的按钮上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



bootstrap文档中有4种方法:

 < a href =#class =btn btn-inforole =button>链接按钮< / a> 
< button type =buttonclass =btn btn-info> Button< / button>
< input type =buttonclass =btn btn-infovalue =Input Button>
< input type =submitclass =btn btn-infovalue =提交按钮>

第一个不适用于我,没有按钮显示,只是带有链接的文本,有一种感觉,它的主题即时通讯使用。第二个显示的按钮,这是我想要的,但什么代码使按钮链接到另一个页面时单击?

干杯

解决方案

按钮。

 < input type =buttonclass =btn btn-infovalue =输入按钮onclick = relocate_home()> 

< script>
函数relocate_home()
{
location.href =www.yoursite.com;
}
< / script>

OR
使用此代码

 < input type =buttonclass =btn btn-infovalue =输入按钮onclick =location.href ='http:\\www.google .com之间;> 


How would one put a link on a button with bootstrap?

there are 4 methods in the bootstrap documentation:

<a href="#" class="btn btn-info" role="button">Link Button</a>
<button type="button" class="btn btn-info">Button</button>
<input type="button" class="btn btn-info" value="Input Button">
<input type="submit" class="btn btn-info" value="Submit Button">

The first one doesn't work for me, no button shows, just the text with the link, have a feeling its the theme im using.

The second one shows the button which is what i want, but whats the code make the button link to another page when clicked?

Cheers

解决方案

You can call a function on click event of button.

<input type="button" class="btn btn-info" value="Input Button" onclick=" relocate_home()">

<script>
function relocate_home()
{
     location.href = "www.yoursite.com";
} 
</script>

OR Use this Code

 <input type="button" class="btn btn-info" value="Input Button" onclick="location.href = 'http:\\www.google.com';">

这篇关于如何把一个链接放在一个带有引导的按钮上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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