+ Reply to Thread
Results 1 to 8 of 8

Thread: jQuery .each()

  1. #1
    pratham.gharat200395 is offline x10Hosting Member pratham.gharat200395 is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    12

    jQuery .each()

    Hi,

    Am trying to change the formatting of a tr (table row) element with jquery.
    I have no control over the table as its generated by another javascript.
    the table/tr has no css class

    each of the alternate tr has a bgcolor attribute specified... I want to remove the value of this attribute so it turns transparent.
    i have paced this script under the javascript that generates the table.

    Code:
    <script language="JavaScript"> $(document).ready( function() { 
    $("#postcontent tr").each( function() { 
    $(this).attr("bgcolor", ""); 
    }); 
    });</script>
    But this gives an error in firebug

  2. #2
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: jQuery .each()

    First thing first, the language attribute is deprecated, the correct way would be <script type="text/javascript">.
    Otherwise your code should be fine. Now I must ask, did you included the jQuery library?
    And last thing, exactly what error is FireBug throwing out?

  3. #3
    pratham.gharat200395 is offline x10Hosting Member pratham.gharat200395 is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    12

    Re: jQuery .each()

    It gives me this error


    Code:
    $ is not a function
    [Break On This Error] $(document).ready( function() {
    btw both the scripts are in the body tag
    and yes, http://code.jquery.com/jquery-1.5.min.js is included in the head tag
    Last edited by pratham.gharat200395; 02-08-2011 at 11:20 PM.

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: jQuery .each()

    Either give the entire page or a URL to it.

    That error message is saying that $ is not a function, which is saying that jQuery is not there.
    Nothing is always absolutely so.

  5. #5
    pratham.gharat200395 is offline x10Hosting Member pratham.gharat200395 is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    12

    Re: jQuery .each()

    it is there...
    <script type='text/javascript' src='http://www.pratham.me/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>

    err i forgot to mention this all is in a wordpress blog.
    www.pratham.me/jobs
    Last edited by pratham.gharat200395; 02-09-2011 at 11:12 PM.

  6. #6
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: jQuery .each()

    If the browser says $ isn't a function, then it isn't defined as a function at the time you're trying to call it. As for the cause, note the call to $.noConflict at the end of http://www.pratham.me/wp-includes/js/jquery/jquery.js.
    Last edited by misson; 02-10-2011 at 04:56 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  7. #7
    pratham.gharat200395 is offline x10Hosting Member pratham.gharat200395 is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    12

    Re: jQuery .each()

    Quote Originally Posted by misson View Post
    If the browser says $ isn't a function, then it isn't defined as a function at the time you're trying to call it. As for the cause, note the call to $.noConflict at the end of ttp://www.pratham.me/wp-includes/js/jquery/jquery.js.
    Thanks for the hint mission(eek where did strikethrough go!?) misson* ! solved the problem.
    Last edited by pratham.gharat200395; 02-10-2011 at 07:52 AM.

  8. #8
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: jQuery .each()

    Lessons:

    1. Pay attention to error messages. They are often cryptic and sometimes useless, but they usually provide clues as to the source of the problem. Include them in any request for help.

    2. Include all the code or a URL. Without the ability to see your copy of jquery.js , finding the culprit would have been impossible.
    Nothing is always absolutely so.

+ Reply to Thread

Similar Threads

  1. Problema con Jquery
    By ferri.fc77 in forum Ayuda Web
    Replies: 0
    Last Post: 12-09-2010, 03:19 AM
  2. jquery help
    By bioshock in forum Scripts & 3rd Party Apps
    Replies: 0
    Last Post: 10-28-2010, 08:47 AM
  3. jQuery.LocalScroll and example of
    By ahmet27 in forum Scripts & 3rd Party Apps
    Replies: 0
    Last Post: 10-16-2010, 01:48 PM
  4. jQuery dialog
    By ahmet27 in forum Scripts & 3rd Party Apps
    Replies: 0
    Last Post: 08-07-2010, 02:51 PM
  5. jQuery & CSS Help...
    By toddart65 in forum Programming Help
    Replies: 7
    Last Post: 05-16-2010, 10:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers