Getting instance of dynamically loaded content

Getting instance of dynamically loaded content

Hi,

Can't find an answer to this anywhere on the web...

Say I have a container:

  1. <div id="xxx" class="parent_container">
  2. ...
  3. </div>

And a script like:

  1. <script type="text/javascript">
  2. $(document).ready(function(){  
  3.   $('#xxx').load('http://dynamic.content');
  4. });
  5. </script> 

This loads the required content into the container and exectutes the javascript found inside dynamic content - great! My problem is: how do I get a jquery reference to loaded element from within dynamic content itself?

What I want to do is something like:

  1. $(this).parents('.parent_container').remove();

if I use $(this) inside the document.ready() function within dynamic content, it will give me a document object. What I want is a reference to the content that is being inserted.

I don't know the ID of the element from within dynamic content scope. 


thanks,
Karolis