简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM