2008-11-05 8 views
1

저는 Jquery를 처음 사용하고 div 컨테이너를 사용하여 URL을로드하려고하지만 사용자에게 옵션을 제공하려고합니다. Amazon.com에서와 같이 오른쪽 상단의 X 기호를 사용하여 페이지를 닫을 수 있습니다. 이것을 달성하는 가장 좋은 방법은 무엇입니까?X 로그인 jquery를 사용하여 load() 페이지를 닫는 가장 효율적인 방법

여기에 내가 가진 무엇 오른쪽 상단이 어디 있는지 파악하고 이미지의 X 배치 서투른 것 같다

$("#url_link_details").click(function() { 
    $("#details").load("tooltip_address.htm", function() { 
     $(this).addClass("openwindow").show(); 
     $(".img_close").addClass("img_close_show").show(); 
    }) 
}); 

어떤 도움 감사합니다.

답변

2

일부 HTML :

<div id="popup"> 
    <img src="x.gif" alt="Close" class="img_close" /> 
    <div class="details"></div> 
</div> 

일부 CSS :

#popup .img_close { 
    float: right; 
} 

#details { 
    clear: right; /* if you want there to be a "titlebar" area */ 
} 

일부 jQuery를

$('#url_link_details").click(function() { 
    $('#details').load('tooltip_address.htm', function() { 
     $('#popup') 
      .show() 
      .find('.img_close') 
      .click(function() { 
       $('#popup').hide(); 
      }) 
     ; 
    }) 
})