atfinho
3 months ago

Jquery prepend issue

Posted 3 months ago by atfinho

Hey guys I'm using jquery

I've a div that includes some inputs, I want to dupplicate it whenever I hit a button.. when the new content is dupplicated I want to add on the top of it another content ( X button) to give option to delete it but it didn't work... I tried using prepend.. here is my code

<script>
$('document').ready(function(){

  var newProduct=$('.box-color').html();
  var newButton=$('.clicked').html();
$('.clicked').click(function(){
// this is content that has to be inserted in the top of dupplicated one
var html="";
html+= '<div class="box-tools pull-right">';
html+='<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>';
html+=' <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-remove"></i></button>';
html+='</div>';

$(newProduct).prepend(html);

$('.box-color').append(newProduct);


});

});

</script>

Please sign in or create an account to participate in this conversation.