Append element ,getting append twice

$('label[id="p-n-from"]').on('click',function() {
    var fromele = $('<div id="p-n-from-'+ifrom+'" class="input-control text"  data-role="input"><span class="mif-location prepend-icon"></span><input id="from['+ifrom+']" placeholder =" Enter Pick Up Location"  type="text" required></div>');
    $(fromDiv).append(fromele);
    return false;           
 }); 

<div class="col-md-6 ">
  <label class="input-control ">From</label>
  <div id="from-div">
    <div id="p-n-from-1" class="input-control text" data-role="input">
      <span class="mif-location prepend-icon"></span>
      <input id="from[0]" placeholder="Enter pickup " type="text" required>
    </div>
  </div>
  <div id="" class="col-md-6 ">
    <label id="p-n-from" class="input-control">
      <button class="button mini-button cycle-button mif-plus fg-green"></button>Add More</label>
  </div>
</div>
<div class="col-md-6 ">
  <div id="to-div">
    <label class="input-control ">To</label>
    <div id="p-n-to-1" class="input-control text" data-role="input">
      <span class="mif-location prepend-icon"></span>
      <input id="to[0]" placeholder="Enter drop location" type="text" required>
    </div>
  </div>

</div>

Answers


If you are using a div only add the inputs, try this:

1 - Add a div in your html

<div id='IdYourDiv'></div>

2 - Configure the script

var fromele = "<input type='text' id='input1'/><br><input type='text' id='input2'/>";
$('#IdYourDiv').html(fromele);

$('label[id="p-n-from"]).unbind();

putting it before the trigger helped .


Need Your Help

Where are the NHibernate/Hibernate HQL and ICriteria query examples?

nhibernate hibernate orm hql icriteria

I'm still quite new to NHibernate and most of it I'm getting to grips with. One area that I'm really lacking a proper understanding of though is querying (at least when it comes to anything reason...