if user click <li><a id="print" href="">출력 하기</a></li>
it's id ="print" so it makes id="print2" button, title is 복사하기. and makes checkbox.
and then if user click id="print2" button "복사하기" it doesn't work. there is no reaction.
what do i miss?
$(document).ready(function(){
$("#print").unbind('click');
$("#print").on('click', function(ev){
$('#main').prepend('<center><button class="btn btn-primary btn-lg" id="print2">복사하기</button></center>')
$('.post').prepend('<input type="checkbox" />');
ev.preventDefault();
});
$("#print2").on('click', function(){
var images ='';
$('li').each(function(){
var thisCheckFlag=$(this).children('input[type="checkbox"]').is(':checked');
if(thisCheckFlag){
images+='<img src ="'+$(this).find('img').attr('src')+'">';
}
});
if(images){
var myWindow=window.open('','printWindow','width=800,height=800');
myWindow.document.write(
'<html><head><title>Print</title></head><body>'
+images+'</body></html>'
);
myWindow.focus();
myWindow.print();
}
else alert('먼저 선택하세요.');
});
});