有人能告诉我为什么声明的函数不适用于 append() 方法创建的元素吗?它确实适用于元素,但是,当使用提到的函数添加另一个元素时,动作不会触发?
info_box var containsg div 使用该函数关闭,$(".notification-close").click(function(){
但是当使用 append() 方法创建框时,它不再起作用。
$(document).ready(function () {
//setTimeout(function(){$(".notification-box").fadeOut("slow");}, 6000);
$(".notification-close").click(function(){
$(".notification-box").fadeOut("slow");return false;
});
// AJAX
$(".lightbox_delete_button").easyconfirm({locale: { title: 'Delete', button: ['No','Yes']}});
$(".lightbox_delete_button").click(function () {
var pictid_lightbox = $(this).parent().find('#pictid_lightbox').val();
var thumb_container = $(this).parents('.thumb_container');
var tools_counter = $('body').find('#tools_lightbox_count').text();
var reduced_tools_counter = parseInt(tools_counter)-1;
var info_box = "<div class=\"notification-box notification-box-info\"><p>You don't have any images in your lightbox</p><a href=\"#\" class=\"notification-close notification-close-info\">x</a></div>";
$.ajax({
url: "ajax.html",
type: "POST",
async:false,
data: ({f:"test_ajax",pictid_lightbox:pictid_lightbox}),
success: function(data){
alert(data);
thumb_container.fadeOut("slow");
$($('body').find('#tools_lightbox_count')).replaceWith('<span id=\"tools_lightbox_count\">' + reduced_tools_counter.toString() + '</span>');
if(reduced_tools_counter == 0){
$('body').find('#center_column').append(info_box);
}else{
alert('not empty');
}
}
});
return false;
});
});