Reputation: 739
HTML
<body>
<input type="button" value="ADD" class="add">
<div class="cont">
<div class="wrapper">
<input type="text" class="txt1">
<input type="text" class="txt2">
<input type="button" value="Delete" class="del">
</div>
</div>
</body>
SCRIPT
$(document).ready(function(e) {
$(".add").on('click',function(){
$(".cont").append$(".wrapper");
});
});
Hi frnds here if I click the add button the whole div has to append. I don't know whether i am going in right way or not. Please guide me.
Upvotes: 0
Views: 99
Reputation: 832
Here is the modified script to work:
Please find preview here: http://plnkr.co/edit/SzVcBpNtujZ3iBSnX21n?p=preview
You need to append .html() function
$(document).ready(function(e) {
$(".add").on('click',function(){
$(".cont").append($(".wrapper").html());
});
});
Upvotes: 3
Reputation: 18873
$(document).ready(function(e) {
$(".add").on('click',function(){
var item = $(".wrapper").eq(0).clone();
$(".cont").after(item);
});
});
EDIT :-
Fiddle Link :- http://jsfiddle.net/cj575cey/1/
Upvotes: 1
Reputation: 2111
.wrapper
is already wrapped by .cont
.
$(document).ready(function(e) {
$(".add").on('click',function(){
$(".cont").append($(".wrapper"));//change append$(".wrapper") to .append($(".wrapper"))
});
});
Upvotes: 1
Reputation: 12117
append$()
is not jQuery function
Chagne
$(".cont").append$(".wrapper");
to
$(".cont").append($(".wrapper"));
OR
$(".wrapper").appendTo(".count")
Upvotes: 1