bootstrap - button href not working when clicking

Viewed 21

Do you know why the following do not work clicking on the "href" on the Button, nothing happens?

    <ul class="list-group list-group-flush">
        <li class="list-group-item px-3 border-0 active text-black">
            <div class="row">
                <div class="col-6 col-sm-2">
                    <strong class="text-gray-dark">App</strong>
                </div>
                <div class="col-6 col-sm-3">Description</div>
            </div>
        </li>
        <button href="https://mydomein.com" type="button" class="list-group-item list-group-item-action">
            <div class="row">
                <div class="col-6 col-sm-2">
                    <strong class="text-gray-dark">Hello World</strong>
                </div>
                <div class="col-6 col-sm-3">Description</div>
            </div>
        </button>
</ul>
1 Answers

I don't think button href="" even works. Either you can use <a> tag or you can try:onclick="window.location.href='https://domein.com'"

Demo

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet" />
<button class="btn btn-success" onclick="window.location.href='https://getbootstrap.com/'">click</button>
And if you are asking logically, In this docs you can check the elements which accepts links.

Related