对按钮元素使用href属性 [英] Using href attribute for button element

查看:114
本文介绍了对按钮元素使用href属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要对按钮使用href=""属性

像这样的<button href="link">click me</button>而不是<a href="link">

那是错的.

我认为我必须尝试这段代码

I think that I've to try this code

<button onClick="FN('MY Link For Example www.stackoverflow.com')" >click me</button>

<script>
function FN('URL'){
     --> Go to MY Link For Example www.stackoverflow.com
}
<script>

那么你们建议我该怎么做?

So what do u guys suggest I should do ?

推荐答案

尝试一下.这将导航到单击链接.

Try this. This will navigate to the link on click.

 <button onclick="window.location.href='http://www.stackoverflow.com'">click me</button>

这篇关于对按钮元素使用href属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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