当前位置: 动力学知识库 > 问答 > 编程问答 >

how to set bootstrap button to active on click using javascript

问题描述:

 <div class="row">

<div class="col-md-8">

<h3 >

<button type=submit class="btn btn-primary btn-lg btn-block" .button><a href = "mrequest.php">make a request</button>

</h3>

</div>

</div>

<div class="row">

<div class="col-md-8"> <h3>

<button type=submit class="btn btn-primary btn-lg btn-block" .button><a href = "mviewreq.php">view requests</button>

</h3>

</div>

</div>

<div class="row">

<div class="col-md-8"> <h3>

<button type=submit class="btn btn-primary btn-active btn-lg btn-block" .button><a href = "mviewstaff.php">Quotation requests</button>

</h3>

</div>

How can I change the button to active when some particular button is clicked , and i also want to use same thing on the navigation tabs too. and make it active too, please can some post any jquery or some thing like that so I can use it. I have searched on internet about it but i am unable to understand it

网友答案:

Add a bootstrap Active class using jquery

<button id="btn1" type=submit class="btn btn-primary btn-lg btn-block" .button>

 $('#btn1').on('click', function (e) {
            $('#btn1').each(function () {
                $(this).addClass('active');
            })

        });

This works well with the navigation , if you replace the ElementId with li.

分享给朋友:
您可能感兴趣的文章:
随机阅读: