admin管理员组文章数量:1426058
I need that use href=""
attribute for button
like this <button href="link">click me</button>
Instead of <a href="link">
that's wrong .
I think that I've to try this code
<button onClick="FN('MY Link For Example www.stackoverflow')" >click me</button>
<script>
function FN('URL'){
--> Go to MY Link For Example www.stackoverflow
}
<script>
So what do u guys suggest I should do ?
I need that use href=""
attribute for button
like this <button href="link">click me</button>
Instead of <a href="link">
that's wrong .
I think that I've to try this code
<button onClick="FN('MY Link For Example www.stackoverflow.')" >click me</button>
<script>
function FN('URL'){
--> Go to MY Link For Example www.stackoverflow.
}
<script>
So what do u guys suggest I should do ?
Share Improve this question edited Jan 21, 2020 at 20:43 isherwood 61.2k16 gold badges122 silver badges170 bronze badges asked May 28, 2015 at 7:38 Danin NaDanin Na 4091 gold badge3 silver badges13 bronze badges 04 Answers
Reset to default 4Try this. This will navigate to the link on click.
<button onclick="window.location.href='http://www.stackoverflow.'">click me</button>
Why you don't use <a type="button" href=""></a>
Or if you really want a button, so <button onclick="window.location.href=""></button>
I think this will solve your problem
<a href="http://www.stackoverflow./">
<button>click me</button>
</a>
href attribute can not be used on button tag , if you want button like appearance for your a tag you can use add style to your a tag and make it look like button , add bootstrap reference then add button class to your anchor tag. Custom Bootstrap Button , but if you still want to use button tag then adding onclick event is better option
本文标签: javascriptUsing href attribute for button elementStack Overflow
版权声明:本文标题:javascript - Using href attribute for button element - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745429807a2658276.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论