appendTo makes HTML code not to work correctly
Hi,
I'm trying to add some HTML code inside a div using appendTo. The HTML code is added and I can see it in the screen, the problem is that I can't "close" the div using the link... but I can "close" the div when the HTML code is loaded in the page (when the HTML is in the website). This is my code:
- jQuery(function(){
- jQuery('.showWindow').click(function(){
- var id = $(this).attr('target');
- $( "<div id='"+id+"' class='window'><div class='window-bar'><div class='window-title'>"+id+"</div><div class='window-tabber'><span class='minimize'><a target='"+id+"' class='minimize'>_</a></span><span class='close'><a target='"+id+"' class='closel'>X</a></span></div></div><div class='window-content'></div></div>" ).hide().appendTo( "#screen" ).fadeIn(999);
- $('#'+$(this).attr('target')).draggable({ containment: "#screen", scroll: false, handle: ".window-bar" });
- $('#'+$(this).attr('target')).resizable({containment: "#screen", minHeight: 200, minWidth: 400});
- $('#'+$(this).attr('target')).position({
- of: $('#'+$(this).attr('target')).parent(),my: 'right top',at: 'right top',
- });
- $('#'+$(this).attr('target')).offset({ top: 60, left: 30 });
- });
- jQuery('.closel').click(function(){
- $('#'+$(this).attr('target')).fadeOut('slow', function(){$(this).remove()});
- });
- });
I know that jQuery already has a window extension/plug-in but I'm trying to build one myself to learn how to use jQuery.
Thanks