Umut Savas
Umut Savas

Reputation: 239

Why do my Bootstrap buttons on mobile not work?

I have Buttons on my website which do work on desktop but not on mobile.

<button type="button" class="btn btn-primary rounded-0"><a href=" 
https://google.com">Google</a></button>

I know that on mobile devices I tap and I don't click. But how can I trigger a tap without js if possible?

Upvotes: 0

Views: 631

Answers (1)

MichaelvE
MichaelvE

Reputation: 2568

Don't use an anchor tag within a button. Use an onClick for the button. Or you can style your anchor as a button:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

<button type="button" onclick="window.location='https://google.com'" class="btn btn-primary rounded-0">Google</button>

<a class="btn btn-primary rounded-0" href="https://google.com">Google</a>

Upvotes: 3

Related Questions