javascript - how to remove text boxdiv on click button -
<img id="plusicondiv" class="rose" src="images/pluseicon.svg" /> <div id="plusicondivbox"class="insidediv " style="margin-top:-53px;" > <img class="mynasicondiv" src="images/mynas.svg" /> </div>
i have 2 icons 1 plusbutton anther mynasbutton want add image , textbox onclick plusbutton icon , when click mynasbutton remove corresponding textbox , image.
$(function () { $('.rose').on('click', function () { var textbox = '<input type="text" class="textbox"/>'; var = $(this).attr("id");alert(a) $('#'+a+"box").append(textbox); var img = '<img class="mynasicondiv" src="vectorimages/mynas.svg"></img>'; $('#' + + "box").append(img); $(function() { $(document).on("click",".mynasicondiv",function () { $(this).parent('#' + + "box").empty(); return $(this).find(".rose").input(); $(this).addclass("texbox"); })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
but problem click mynasbutton text box removed.
try code
<script type="text/javascript" src="jquery.min.js"></script> <section id="main-content"> <section class="wrapper"> <!-- basic form elelemnts --> <div class="row mt"> <div class="col-lg-12"> <div class="form-panel"> <h4 class="mb"><i class="fa fa-angle-right"></i>multi picture</h4> <form class="form-horizontal style-form" method="post" id="multi_image" enctype="multipart/form-data"> <input type="hidden" class="form-control" name="user_id" > <div class="form-group"> <label class="col-sm-2 col-sm-2 control-label">picture 1</label> <div class="col-sm-10 upload_div"> <div style="float:left;width:30%;"> <input type="file" name="userfile[]"> </div> </div> </div> <div class="other_files"> </div> <div class="form-group"> <div class="col-sm-10"> <a href="javascript:void(0);" class="btn btn-primary add_btn" id="add_btn" style="width:20%;margin-right:col-sm-100px;">add</a> <button class="btn btn-primary" type="submit">upload</button> </div> </div> </form> </div> </div><!-- col-lg-12--> </div><!-- /row --> </section> </section> <script type="text/javascript"> $(document).ready(function(){ var max_upload=5; var addbutton=$('.add_btn'); var wrapper=$('.other_files'); var x=1; $(addbutton).click(function(){ if(x < max_upload) { x++; var new_html='<div class="form-group">'; new_html+='<label class="col-sm-2 col-sm-2 control-label">picture ' + x + '</label>'; new_html+='<div class="col-sm-10 upload_div">'; new_html+='<div style="float:left;width:30%;">'; new_html+='<input type="file" name="userfile[]">'; new_html+='</div>'; new_html+='<div style="width:70%;">'; new_html+='<a href="javascript:void(0);" class="btn btn-danger delete_class" id="delete_id" style="width:20%;">delete</a>'; new_html+='</div>'; new_html+='</div>'; new_html+='</div>'; wrapper.append(new_html); } }); $(wrapper).on('click','.delete_class',function(e){ e.preventdefault(); $(this).parent().parent().parent().remove(); x--; }); }); </script>
Comments
Post a Comment