Home › Forums › JavaScript › JQuery on checkbox check › Re: JQuery on checkbox check
@Hompimpa, you don’t need to re-call or even repeat the the function after the elements have been injected, the beauty of the .on() function is that it will attach the event hander to any existing or any element added to the dom that matches the selector,
@justinweb, the document.ready function you have posted also seems wrong to me, it may work but i’ve never seen a $(window).ready call used,
Try the following code should work,
$(document).ready(function(){
$(‘.select_post’).on(‘click’, function () {
alert(‘click’);
$(‘#delete_post_button’).css(‘display’, ‘block’);
});
$.post(‘load_posts.php’,function(rows){
$(‘#post_list’).empty();
$.each(rows,function(i){
var row = rows,
id = row[0],
date = row[1],
title = row[2],
postContent = ‘
‘‘ +
‘
‘‘ +
‘‘ +
‘‘ +
‘
‘ +
‘‘ +
‘
‘ + date + ‘
‘ +
‘
‘;
$(‘#post_list’).append(postContent);
});
});
});