"Toggle focus , add remove class on focus"
Bootstrap 4.1.1 Snippet by naimansari

<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 ----------> <div class="wrapper"> <label for="name" class="required">name</label> <div class="data_area"> <input type="text" id="" name="" value="" title="" class="" /> </div> </div>
.searchExp { background:#f33; }
jQuery(document).ready(function(){ jQuery('.wrapper input').focus(function () { jQuery(this).parent().addClass('searchExp'); }).blur(function () { jQuery(this).parent().removeClass('searchExp'); }); });

Related: See More


Questions / Comments: