"pruebas"
Bootstrap 3.2.0 Snippet by XhamirM

<link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="form-group" id="pago-div"> <label for="amount" class="col-sm-3 control-label">Pago</label> <div class="col-sm-3"> <input type="number" class="form-control" id="amount" name="amount"> </div> <div class="col-sm-4"> <select id="f_pago" name="f_pago" class="form-control" required=""> <option>Efectivo</option> <option>Tarjeta</option> <option>Deposito</option> <option>Cheque</option> <option>Transferencia</option> </select> </div> <div class="col-sm-2"> <button type="button" class="btn btn-default pay-add-button" id="click-me"> <span class="glyphicon glyphicon-plus"></span></button> </div> </div>
Array.prototype.remove = function(x) { var i; for(i in this){ if(this[i].toString() == x.toString()){ this.splice(i,1) } } } var array = []; var pivot = ""; $(document).on('change', '#f_pago', function(){ array.pop(); $("option:selected",this).each(function(){ array.push($(this).text().trim()); }); console.log(array); }); $(document).on('click', '#remove-me', function(){ var superparent = $(this).parent().parent(); var option = $(superparent).find("#f_pago > option:selected"); array.remove($(option).text().trim()); console.log(array); $(superparent).remove(); }); //$(document).on('click',"#click-me",function(){ // $("#f_pago").prop("disabled",true); // $("body").find("#f_pago option:selected").each(function(){ // if($(this).text().trim() === pivot){ // $(this).parent().prop("disabled",false); // } //}); //}); $(document).ready(function(){ var divlala = $("#sosin"); var span = $("<span></span>"); span.text("Dos"); divlala.append(span); $("#f_pago option:selected").each(function(){ array.push($(this).text().trim()); }); console.log(array); $("#click-me").click(function(){ //console.log("hola0"); //console.log($(this).parent().parent()); //var id = $(this).parent().parent().attr("id"); //console.log($("#"+id+" > #f_pago")); //$("#"+id+" > #f_pago").prop("disabled", true); var new_pago = $("#pago-div").clone(); new_pago.appendTo("body"); $(new_pago).find("#f_pago option").each(function(){ var search_val = $(this).text().trim(); if(jQuery.inArray(search_val, array) > -1){ $(this).remove(); console.log("Encontre "+ $(this).text()); } // break }); $(new_pago).find("#f_pago option:selected").each(function(){ var selected = $(this).text().trim(); //array.push(selected); //pivot = selected; //console.log(pivot); }); $(new_pago).find("#click-me > span").attr("class","glyphicon glyphicon-minus"); $(new_pago).find("#click-me").attr("id", "remove-me"); console.log(array); }); //alert(jQuery.inArray("Dos",array)) });

Related: See More


Questions / Comments: