javascript - Add Classes On TextBox foucusout event via jQuery -
hi succeeded remove classes on edit button click, having issue adding classes back.
here code given below.
any appreciated.
$(document).ready(function() { $(".edit").click(function() { $(this).parent().find('.edit-field-area').removeclass('edit-field-area'); $(this).removeclass('edit-button'); $(this).parent().find('.transparent-control').prop('disabled', false); $(this).parent().find('.transparent-control').focus(); }); $(".transparent-control").focusout(function() { debugger; $(this).parent().find('.row').find('.edit').addclass('edit-button'); $(this).prop('disabled', true); }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <!-- latest compiled , minified css --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <div class="row"> <div class="col-md-3"> <img src="images/side-border.png" width="100" height="20" /> <img src="http://localhost:49606/img/thumbnail5.jpg" class="img-circle" width="100" height="100" alt="muhammad essa" /> </div> <div class="col-md-9"> <div class="row"> <div class="col-md-10 edit-field-area heading-one"> <input type="text" id="name" disabled="disabled" class="transparent-control" value="muhammad essa rind" /> </div> <div class="col-md-1 col-md-offset-1 edit-button heading-one edit" style="margin-left: 10px;"> <h3 style="margin-top: 9px"><i class="glyphicon glyphicon-pencil"></i></h3> </div> </div> <div class="row"> <div class="col-md-10 edit-field-area"> <input type="text" id="job" class="transparent-control" value="software developer @ united marine agencies pvt ltd" /> </div> <div class="col-md-1 col-md-offset-1 edit-button edit" style="margin-left: 10px;"> <h5><i class="glyphicon glyphicon-pencil"></i></h5> </div> </div> <div class="row"> <div class="col-md-10 edit-field-area"> <input type="text" id="country" class="transparent-control" value="pakistan" /> </div> <div class="col-md-1 col-md-offset-1 edit-button edit" style="margin-left: 10px;"> <h6><i class="glyphicon glyphicon-pencil"></i></h6> </div> </div> </div> </div>
the simple idea adding class on textbox focus out in demo, please click see
replace $(this).parent().find('.row').find('.edit').addclass('edit-button'); $(this).addclass('edit-button');
Comments
Post a Comment