Home > other >  bootstrap - button href not working when clicking
bootstrap - button href not working when clicking

Time:09-19

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

    <ul >
        <li >
            <div >
                <div >
                    <strong >App</strong>
                </div>
                <div >Description</div>
            </div>
        </li>
        <button href="https://mydomein.com" type="button" >
            <div >
                <div >
                    <strong >Hello World</strong>
                </div>
                <div >Description</div>
            </div>
        </button>
</ul>

CodePudding user response:

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/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
<button  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