Thanks. I ended up largely solving my problem via what turned out to be a related issue having to do with a selector I was using to get the node to append to (there were many new nodes created on the fly for appending into). I was using classes 3 deep for the selector and changed my code so that the node being selected got a unique id and then used that.

- Jack

ricardobeat wrote:
This should be a little bit faster:

var $divB = ('.divB', '#wrapper');
$('#divA').children('.a-specific-class').appendTo($divB[0]);

If it's possible, try moving a single wrapper element containing all
the links, that will be certainly faster.

- ricardo

On Feb 26, 8:40 pm, Jack Killpatrick <j...@ihwy.com> wrote:
Hi All,

I have a need to move a few hundred dom nodes from one place in a page
to another place. For example, to take all link tags inside a div and
move them to another div, like from divA to divB below:

<div id="divA">
    <a href="#">Link</a>
    <a href="#">Link</a>
    <a href="#">Link</a>
    <a href="#">Link</a>
    <a href="#">Link</a>
    <a href="#">Link</a>
</div>

<div id="wrapper">
    <div class="divB">
    </div>
</div>

I'm using jquery 1.3.2 (and have not tried 1.2.6 yet). I've found that
in FF, Safari and Opera using .append() works OK: the append happens
fairly fast, but in IE6/7 it's really slow. I'm not sure of the nature
of the slowdown. My code is something like this:

var $myContext = $('#wrapper'); // var already available

var $divB = ('.divB', $myContext);
$('#divA').children('.a-specific-class').each(function(){
  $divB.append($(this));

});

Anyway, I'm wondering if anyone has any advice or best practice to
recommend for doing something like this, in particular with respect to
getting decent speed on IE6/7. The speed I'm seeing seems to be ~20-30x
slower than the other browsers.

Ideally, I'd like to preserve any event handlers (that some other code
may have added to the nodes I'm moving), which is why I'm using
.append($(this)), but it's not completely mandatory if there's no way to
do so and keep the speed.

Thanks,
Jack


Reply via email to