Create elements and functions
Hi guys,
Im initiate with jQuery now and trying to create some elements and, after that, create functions for this. What i do is:
$(document).ready(function(){
$(".open-lightbox").click(function(){
$("#lightbox").css("display","block");
$("<div />").attr("class", "bg-lightbox").appendTo("body");
$("<div />").attr("class", "confirmation-box").html($(this).attr("title")).appendTo("body");
$("<div />").attr("class", "buttons-lightbox").appendTo(".confirmation-box");
$("<a />").attr({"class":"close-lightbox","href":"#"}).text("Close").appendTo(".buttons-lightbox");
})
$(".close-lightbox").click(function(){
$('.bt-lightbox').css('display','none');
$('.bt-lightbox').text('')
})
})
The "open function" works fine, but when i try to execute the "close function" i cant get he result. Its seems like after create element, i cannot use any action with jquery for.
Please, help me with this. I know, probably this is very simple, but i need to practice step by step.
Best Regards,
Rafael Simões