title: jQuery TypeError: <whatever> is not a function in Firefox on table object
body: <p>I am using FireQuery in Firefox.  Here is what I am trying to do:</p>
  
  <ol>
  <li>The text "Items Ordered" exists within a  tag somewhere on
  the page.</li>
  <li>The table that "Items Ordered" text exists in is also nested deep within several other tables.</li>
  </ol>
  
  <p>Given the above scenario, I want to grab the <code>&lt;table&gt;</code> tag closest to the aforementioned string, and append a div to it.  My standard methodology to ensure I've grabbed the correct DOM element is to change the background color and give it a 1px border so that it pops out and is easily discernable on the page.  However, with my code that failed.  So, I'm trying to understand why it failed and how to fix it before proceeding to append the div.</p>
  
  <p>Following is my code I used for testing:</p>
  
  <h2><strong>[HTML -- Actual code, with substituted personal information &amp; links]</strong></h2>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
  
  &lt;html&gt;
  &lt;head&gt;
      &lt;!-- 2013.04.20 --&gt;
  
      &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"&gt;
  &lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          jQuery(document).ready(function() {
                  jQuery('div').css({
                      'border':'solid green 2px'
                  })                
  
                  var elems_arr = jQuery('table:contains(Items Ordered)')
                  console.info('elems_arr:');
                  console.log(elems_arr);
  
                  console.info("elems_arr.length = " + elems_arr.length);
                  target = elems_arr[elems_arr.length - 1]
                  console.warn("target:");
                  console.log(target);                
  
                  var elementType = target.tagName.toLowerCase();
                  alert(elementType);                
  
                  // try wrapping target element in a div with id
                  target.wrap("&lt;div id='target_wrap' /&gt;");                
  
              });
      &lt;/script&gt;
      &lt;style type='text/css'&gt;
          table {
                  border: solid blue 1px;
                  min-height: 30px;
              }
      &lt;/style&gt;
  
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;table&gt;
          &lt;tbody&gt;
              &lt;tr bgcolor="#FFFFFF"&gt;
                  &lt;td valign="top" colspan="2"&gt;
                      &lt;table width="100%" border="0" cellspacing="0" cellpadding="5"&gt;
                          &lt;tbody&gt;
                              &lt;tr bgcolor="#FFFFFF"&gt;
                                  &lt;td&gt;
                                      &lt;center&gt;
                                          &lt;b class="sans"&gt;Shipping Soon&lt;/b&gt;
                                      &lt;/center&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/tbody&gt;
                      &lt;/table&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
                  &lt;td bgcolor="#FFFFFF" valign="top" colspan="2"&gt;
                      &lt;table width="100%" border="0" cellspacing="0" cellpadding="2"&gt;
                          &lt;tbody&gt;
                              &lt;tr valign="top"&gt;
                                  &lt;td width="100%"&gt;
                                      &lt;table border="0" cellspacing="0" cellpadding="2" align="right"&gt;
                                          &lt;tbody&gt;
                                              &lt;tr valign="top"&gt;
                                                  &lt;td align="right"&gt;&amp;nbsp;&lt;/td&gt;
                                              &lt;/tr&gt;
                                          &lt;/tbody&gt;
                                      &lt;/table&gt;&lt;input type="hidden" name="qmsjtomutmooy" value="1"&gt;
  
                                      &lt;table border="0" cellspacing="2" cellpadding="0" width="100%"&gt;
                                          &lt;tbody&gt;
                                              &lt;tr valign="top"&gt;
                                                  &lt;td valign="top"&gt;&lt;b&gt;Items Ordered&lt;/b&gt;&lt;/td&gt;
  
                                                  &lt;td align="right" valign="top"&gt;&lt;b&gt;Price&lt;/b&gt;&lt;/td&gt;
                                              &lt;/tr&gt;
  
                                              &lt;tr&gt;
                                                  &lt;td colspan="1" valign="top"&gt;1 of: &lt;i&gt;SET OF 3 NAIL FILES AT INTRODUCTION PRICE!!! Premium Manicure Crystal Glass Nail Files Nail File By Cheeky. Menicure / Pedicure Set of 3 Crystal Nail&lt;/i&gt;&lt;br&gt;
                                                  &lt;span class="tiny"&gt;Condition: New&lt;br&gt;
                                                  Sold by: Cheeky-Beauty (&lt;a href="#"&gt;seller profile&lt;/a&gt;)&lt;br&gt;&lt;/span&gt;&lt;/td&gt;
  
                                                  &lt;td align="right" valign="top" colspan="2"&gt;$8.99&lt;br&gt;&lt;/td&gt;
                                              &lt;/tr&gt;
                                          &lt;/tbody&gt;
                                      &lt;/table&gt;&lt;br&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/tbody&gt;
                      &lt;/table&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
                  &lt;td bgcolor="#FFFFFF" valign="top" colspan="2"&gt;
                      &lt;table width="100%" border="0" cellspacing="0" cellpadding="2"&gt;
                          &lt;tbody&gt;
                              &lt;tr&gt;
                                  &lt;td&gt;
                                      &lt;b&gt;Shipping Address:&lt;/b&gt;&lt;br&gt;
  
                                      &lt;div class="displayAddressDiv"&gt;
                                          &lt;ul class="displayAddressUL"&gt;
                                              &lt;li class="displayAddressLI displayAddressFullName"&gt;MY NAME&lt;/li&gt;
  
                                              &lt;li class="displayAddressLI displayAddressAddressLine1"&gt;123 Sesame St.&lt;/li&gt;
  
                                              &lt;li class="displayAddressLI displayAddressCityStateOrRegionPostalCode"&gt;Beverly Hills, CA 90210&lt;/li&gt;
  
                                              &lt;li class="displayAddressLI displayAddressCountryName"&gt;United States&lt;/li&gt;
                                          &lt;/ul&gt;
                                      &lt;/div&gt;&lt;br&gt;
                                      &lt;b&gt;Shipping Speed:&lt;/b&gt;&lt;br&gt;
                                      Two-Day Shipping&lt;br&gt;
                                  &lt;/td&gt;
  
                                  &lt;td align="right"&gt;
                                      &lt;table border="0" cellpadding="0" cellspacing="1"&gt;
                                          &lt;tbody&gt;
                                              &lt;tr valign="top"&gt;
                                                  &lt;td nowrap="nowrap" align="right"&gt;Item(s) Subtotal:&lt;/td&gt;
  
                                                  &lt;td nowrap="nowrap" align="right"&gt;$8.99&lt;/td&gt;
                                              &lt;/tr&gt;
  
                                              &lt;tr valign="top"&gt;
                                                  &lt;td nowrap="nowrap" align="right"&gt;Shipping &amp;amp; Handling:&lt;/td&gt;
  
                                                  &lt;td nowrap="nowrap" align="right"&gt;$0.00&lt;/td&gt;
                                              &lt;/tr&gt;
  
                                              &lt;tr valign="top"&gt;
                                                  &lt;td nowrap="nowrap" align="right"&gt;&amp;nbsp;&lt;/td&gt;
  
                                                  &lt;td nowrap="nowrap" align="right"&gt;-----&lt;/td&gt;
                                              &lt;/tr&gt;
  
                                              &lt;tr valign="top"&gt;
                                                  &lt;td nowrap="nowrap" align="right"&gt;Total before tax:&lt;/td&gt;
  
                                                  &lt;td nowrap="nowrap" align="right"&gt;$8.99&lt;/td&gt;
                                              &lt;/tr&gt;
  
                                              &lt;tr valign="top"&gt;
                                                  &lt;td nowrap="nowrap" align="right"&gt;Sales Tax:&lt;/td&gt;
  
                                                  &lt;td nowrap="nowrap" align="right"&gt;$0.00&lt;/td&gt;
                                              &lt;/tr&gt;
  
                                              &lt;tr valign="top"&gt;
                                                  &lt;td nowrap="nowrap" align="right"&gt;&amp;nbsp;&lt;/td&gt;
  
                                                  &lt;td nowrap="nowrap" align="right"&gt;-----&lt;/td&gt;
                                              &lt;/tr&gt;
  
                                              &lt;tr valign="top"&gt;
                                                  &lt;td nowrap="nowrap" align="right"&gt;&lt;b&gt;Total for This Shipment:&lt;/b&gt;&lt;/td&gt;
  
                                                  &lt;td nowrap="nowrap" align="right"&gt;&lt;b&gt;$8.99&lt;/b&gt;&lt;/td&gt;
                                              &lt;/tr&gt;
  
                                              &lt;tr valign="top"&gt;
                                                  &lt;td nowrap="nowrap" align="right"&gt;&amp;nbsp;&lt;/td&gt;
  
                                                  &lt;td nowrap="nowrap" align="right"&gt;-----&lt;/td&gt;
                                              &lt;/tr&gt;
                                          &lt;/tbody&gt;
                                      &lt;/table&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/tbody&gt;
                      &lt;/table&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <h2>Using</h2>
  
  <ul>
  <li>Firefox 20</li>
  <li>Windows Vista Business 32-bit SP2</li>
  <li>Firebug</li>
  <li>Firequery</li>
  <li>Google CDN-hosted jQuery</li>
  </ul>
  
  <h1>What I've found and why it was insufficient</h1>
  
  <p><hr></p>
  
  <h2>A) No conflict</h2>
  
  <p>Many posts on the "is not an error" function indicate that the poster is using "$" instead of "jQuery" and have to do with setting no conflict mode as in <a href="https://stackoverflow.com/questions/7975093/typeerror-undefined-is-not-a-function-evaluating-document">this post</a>.  I don't believe this has anything to do with my issue, though the message is similar, because how I'm implementing jQuery is from FireQuery's "jQueryify" function.  Also, I'm already using "jQuery" instead of "$".</p>
  
  <h2>B) jQuery versions issues</h2>
  
  <p>I also started to suspect the issue may be related to jQuery versions. As of this writing, version 2.0.0 was just released 3 days ago (Apr 18, 2013), and version 1.9.0 is already known to be significantly different from previous versions (including deprecating several popular functions), such that any code using the previous jQuery versions may need to be reworked, either manually or using the <a href="http://blog.jquery.com/2013/01/15/jquery-1-9-final-jquery-2-0-beta-migrate-final-released/" rel="nofollow noreferrer">Migrate tool</a>.</p>
  
  <h3>Results</h3>
  
  <p>So, I tested my code with KOMODO IDE 6.1.3 to eliminate any issues with how FireQuery implements jQuerify.  I used three popular versions of jQuery; here are the results of my cross-browser tests:</p>
  
  <pre><code>* Chrome 26.0.1410.64 m
      - jQuery 1.5.1                    
        Uncaught TypeError: Object #&lt;HTMLTableElement&gt; has no method 'wrap'         codeTest_jQuery_2013.04.20_01.php:28
        (anonymous function)                                                        codeTest_jQuery_2013.04.20_01.php:28
        f.resolveWith                                                               jquery.min.js:16
        d.extend.ready                                                              jquery.min.js:16
        c.addEventListener.A                                                        jquery.min.js:16
  
      - jQuery 1.7.1
        Uncaught TypeError: Object #&lt;HTMLTableElement&gt; has no method 'wrap'         codeTest_jQuery_2013.04.20_01.php:28
        (anonymous function)                                                        codeTest_jQuery_2013.04.20_01.php:28
        n                                                                           jquery.min.js:2
        o.fireWith                                                                  jquery.min.js:2
        e.extend.ready                                                              jquery.min.js:2
        c.addEventListener.B                                                        jquery.min.js:2
  
      - jQuery 1.9.1
        Uncaught TypeError: Object #&lt;HTMLTableElement&gt; has no method 'wrap'         codeTest_jQuery_2013.04.20_01.php:28
        (anonymous function)                                                        codeTest_jQuery_2013.04.20_01.php:28
        c                                                                           jquery.min.js:3
        p.fireWith                                                                  jquery.min.js:3
        b.extend.ready                                                              jquery.min.js:3
        H                                                                           jquery.min.js:3
  
  
  * Firefox 20.0.1
      - jQuery 1.5.1
        TypeError: target.css is not a function
        http://localhost/codeTest_jQuery_2013.04.20_01.php
        Line 30
  
      - jQuery 1.7.1
        (same error)
  
      - jQuery 1.9.1
        (same error)
  
  
  * Internet Explorer 8.06
      - jQuery 1.5.1
        Object doesn't support this property or method
        codeTest_jQuery_2013.04.20_01.php, line 28 character 17
  
      - jQuery 1.7.1
        (same error)
  
      - jQuery 1.9.1
        (same error)
  </code></pre>
  
  <h2>C) Wrap target element with div</h2>
  
  <p>In my code I threw in something to return the type of object.  This is what I used:</p>
  
  <pre><code>// report element type
  var elementType = target.tagName.toLowerCase();
  alert(elementType);   // table
  </code></pre>
  
  <p>It returns "table", so I know I DO indeed have an html element.</p>
  
  <p>Then I figured maybe since the table element is anonymous (no id or name) that was what was causing the problem?  To resolve that I tried to wrap the target tag in a div thusly:</p>
  
  <pre><code>// try wrapping target element in a div with id
  target.wrap("&lt;div id='target_wrap' /&gt;");
  </code></pre>
  
  <p>However, it only returned the same "not a function" error, but this time referencing the wrap() method.  I verified that <a href="http://api.jquery.com/wrap/" rel="nofollow noreferrer">"wrap()" is INDEED a valid jQuery function</a>.</p>
  
  <h2>D) Other thoughts</h2>
  
  <p><a href="https://stackoverflow.com/questions/9435505/jquery-uncaught-typeerror-objectobject-object-has-no-method-slider">This post</a> mentions that Chrome's version of the "Not a Function" error is the "Uncaught TypeError" error.  It suggests multiple instances of jQuery on the same page as a possible cause.  Again, this has to do with noConflict, and I'm not exactly certain if this applies to me or not, though I'm leaning towards 'not'.</p>
  
  <p>The only other thing I could come up with is that maybe the issue has somehting to do with discrepancies and differentiation and differences between jQuery objects, DOM objects, and JavaScript objects?</p>
  
  <p>During the process of starting to post this, I found <a href="https://stackoverflow.com/questions/13669579/object-object-has-no-method-methodex">this jQuery post</a> which may be relevant, but I can't understand it.  It seems to recommend implementation of some plugin or package -- how can I tell if this is just someone trying to promote their code, or if it is an actual, "best practice", accepted module?</p>