2015-08-07 2 views
0

Я хочу добавить кнопку удаления в свой элемент клона для некоторых целей.Как удалить элемент clone - jquery

HTML

<div class="more">add</div> 
     <div id="other_fee"> 
     <div> 
      <input type="text" value="" name="other" placeholder="Description" /> 
      <input class="short3 theAmount" type="text" value="" name="other_amount" placeholder="Amount" /> 
      <div class="inputBlocker"></div> 
     </div> 
     </div> 

JQuery

<script type="text/javascript"> 
     jQuery(function($) { 
     $('.more').on('click', function() { 
      var $table = $('#other_fee'); 
      var $tr = $table.find('div').eq(0).clone(); 
      $tr.appendTo($table).find('input').val(''); 
     }); 

     $("#abc").each(function() { 
      var form = $(this); 

      form.on('keyup', '.theAmount', function() { 
      var sum = 0; 
      form.find('.theAmount').each(function() { 
       sum += +this.value; 
      }); 

      form.find("#other_total").val(sum); 
      }); 
     }); 
     }); 


</script> 
+1

Вы можете разместить свой вопрос с разрядными более подробной информации –

ответ

0

Вы можете просто добавить этот код

в HTML

`<a href=";" class="add">add</a> 
<div class="more hidden"> 
    <div id="other_fee"> 
    <div> 
     <input type="text" value="" name="other" placeholder="Description" /> 
     <input class="short3 theAmount" type="text" value="" name="other_amount" placeholder="Amount" /> 
     <div class="inputBlocker"></div> 
    </div> 
    </div> 

`

в SCRIPT

`$(document).on('click','.add',function(){ 
    $('.more').toggle('hidden'); 
});` 

// или

`$(document).on('click','.add',function(){ 
    if($('.more').hasClass('hidden')){ 
     $('.more').removeClass('hidden'); 
    }else{ 
     $('.more').addClass('hidden'); 
    } 
});` 
Смежные вопросы