"add Multiple class on click"
Bootstrap 4.1.1 Snippet by sunil8107

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery slide Left and Right Toggle Effect</title> </head> <body> <div class="main_div"> <button type="button" class="btn">Button</button> <hr> <div class="box"> <h2>Lorem Ipsum dolor sit amet</h2> </div></div> </body> </html>
.main_div{text-align:center; padding:20px;} .box{ background:#4795ff; padding:20px; color:#fff;} .box.no_highlight{ background:#f2c011;} .box.red_highlight{ background:#f28011;}
$(document).ready(function(){ $('.btn').on('click', function(){ if($('.box').hasClass('no_highlight')){ $('.box').removeClass('no_highlight').addClass('red_highlight'); }else{ $('.box').addClass('no_highlight'); } }); });

Related: See More


Questions / Comments: