Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3997152
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:22:01+00:00 2026-05-20T07:22:01+00:00

JQuery Version jQuery JavaScript Library v1.4.4 Problem The solution may be blatantly obvious, however

  • 0

JQuery Version

jQuery JavaScript Library v1.4.4

Problem

The solution may be blatantly obvious, however I’m scratching my head.

The problem is while doing some code optimisation I came across a loop that called append on a jquery element a few times and it was a rather large loop. So it looked something like this:

var list_of_goodies = [1,2,3,...];
$.each(list_of_goodies, function(val) {
      $('div.toaddto').append(val);
      ...some more code...
      $('div.toaddto').append(otherval);
});

As you can see not really optimised so I tried to use function pointers so it looked something like this:

var list_of_goodies = [1,2,3,...];
var toaddtoAppend = $('div.toaddto').append;
$.each(list_of_goodies, function(val) {
      ... the other code...
      toaddtoAppend(val).append(otherval);
});

It may not seem like a huge optimisation, but it’s a large list and this can save a lot of lookup time especially in the older IE’s.
This however causes an error.

The Error

this.domManip is not a function

Unfortunately this is from the minified jQuery, so there isn’t much more info, it seems to happen within wrapInner() however.

Question

Is this a scope issue or a reference issue? I’ve tested it without using jQuery and the function pointer worked.

$.each or a for loop end up with the same results. Anyone know where I’m going wrong here?
I know very little about how javascript handles function pointers, especially when they’re supposed to be associated to an instance of something as opposed to just static, so forgive any ignorance here.

Browsers Tested In

  • Firefox 3.6
  • IE 6, 7 & 8
  • Chrome 9.0.something

Regardless of the browser the results are always the same, which seems to suggest it’s not how the browser is handling the pointer that’s causing it to break.

Test it Yourself

<html>
   <head>
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
     <script type="text/javascript">   
         $(function(){
            var iterables = [];
            for (var i = 0; i < 1000; i++) iterables.push(i);
            var divAppend = $('#test').append;
            $.each(iterables, function(val) {
               divAppend(val);               
            });
         });       
      </script>
   </head>
   <body>
      <div id="test"></div>
   </body>
</html>

Thanks,
dennmat

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:22:01+00:00Added an answer on May 20, 2026 at 7:22 am

    When you write var divAppend = $('#test').append, you’re storing a reference to jQuery’s standard append function.
    It’s equivalent to writing var divAppend = $.fn.append—$('#test') isn’t stored anywhere.

    When you call divAppend as a normal function, its this is window, not a jQuery object.

    You need to store a function that explicitly calls $('#test').append(...), or use divAppend.call($('#test'), val) to explicitly call append on the right object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

jQuery and JavaScript in general are new ground for me. What are some good
I'm developing a javascript widget that depends on jQuery. The widget may or may
I have used jQuery UI library to drag divs within a web page. While
This is the piece of code I have written: <html> <head> <script type=text/javascript src=jquery-min.js></script>
Quick question: can I use a JavaScript library (i.e. jQuery) in developing a Mac
I am using JavaScript and the jQuery library on my site. I want to
How do I get the BlackBerry OS version via javascript or jquery in a
I have a web application that uses the current version of JQuery that needs
Is there a case insensitive version of the :contains jQuery selector or should I
I'm having trouble with the droppable effect in jquery 1.3.1 (UI version 1.5.3). As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.