Your .load('drawer.html') call is asynchronous, meaning while it's off
fetching the page, your chain keeps right on going. It doesn't find an
a#close inside #drawer (since the page hasn't come back/loaded yet).
Fortunately, you can provide a callback function to .load() that will be
executed as soon as the page comes in. Something like this (untested):

$('#drawer').load('drawer.html', function() {
  var drawer = $(this);
  $('a#close', drawer).click(function() {
    drawer.hide();
  });
});

- Richard

On Thu, Dec 11, 2008 at 11:33 PM, RayBaker <raymondbake...@yahoo.com> wrote:

>
> I can't seem to get this snippet I loaded with .load to go away once
> loaded.  Any ideas?
>
>
> Here's the function
>  $('a.drawer').click(function() {
>     $('#drawer').show();
>         $('#drawer').load('drawer.html').find('a#close').click(function(){
>                $('#drawer').hide();
>     });
>  });
>
>
> Drawer.html has an anchor with an ID of "close".
>
> Its nested in a div called #outter.
>
>  <div id="outter"><a id="close"><img src="images/close.gif" width="55"
> height="17" border="0" /></a></div>
>

Reply via email to