replaceWith, keeps reference of replaced object?

replaceWith, keeps reference of replaced object?

Hi,

I replace an element with another element:

  1. $("iframe").each(function(){
  2. var frame=$(this);
  3. $(this).contents().find("div").each(function(){
  4. var ID=$(this).attr('pid');
  5.     var span=document.createElement("span");
  6.     span.innerHTML=$(this).html();    
  7.     span.setAttribute('pid',ID);
  8.     $(this).replaceWith( $(span) );
  9.        });
  10. });
The div disappears. However, if after this I make a find in frame contents, with a scrollTo to each find it moves to the disappeared div, despite not being there. Does the frame keeps the reference of the replaced object? How to get rid of it?