Reputation: 7971
I am appending div in existing div and then one more div into append div but it not work for me. what am I doing wrong. please help
<head>
<script type="text/javascript">
$(function(){
$('a').click(function(){
var cl=$('#free').clone();
var jj=$('.append')
var mm=jj.append('<div class="hii"></div>')
mm.append(cl)
})
})
</script>
</head>
<body>
<div style="background:#F00; width:500px; height:50px" id="free"></div>
<a href="#">hide</a>
<div class="append"></div>
</body>
Upvotes: 0
Views: 377
Reputation: 30453
jj.append('<div class="hii"></div>')
return jj
, not new div. So use this:
$(function(){
$('a').click(function(){
var cl = $('#free').clone();
var jj = $('.append');
var mm = $('<div class="hii"></div>');
jj.append(mm);
mm.append(cl);
});
});
Upvotes: 2