Return empty the value of a text field cloned in Javascript

0

I am using VUEjs 2. First steps in programming. Any other better way to achieve this would be appreciated. I am creating a form creator here I have the code in jsBin link I need help in creating the checkboxes . Thank you very much in advance. * First time I write in Stack * The problem is that when cloning the input it is already with the text that you have written in the cloned input.

Div Cloned:

<div id="option" class="input-group form-group">
    <input id="" type="text" class="form-control input-sm" placeholder="Option" value=""> 
<span class="input-group-btn">
    <button type="button" class="btn waves-effect btn-default btn-sm"><i class="glyphicon glyphicon-remove text-danger"></i></button>
</span> 
</div>
<div id="newOptions"> <!-- Div's clonados -->

</div>
<div class="pull-right">
    <button type="button" class="btn waves-effect btn-success btn-xs" @click="addOption"><i class="glyphicon glyphicon-plus-sign"></i> Add option</button>
</div>

This is my JS

addOption: function(){
          var el = document.getElementById("option");
          var divClone = el.cloneNode(true),
              elChild = document.createElement("div"); 

          document.getElementById("newOptions").appendChild(divClone);
        },
    
asked by ivanmercado9 19.04.2017 в 21:41
source

1 answer

0

try using this right after cloning, or as best practice leaves a set of hidden fields which clonara to use, so you do not have the problem that they go with text entered by the user:

divClone.val('');
    
answered by 19.04.2017 в 22:23