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

  • SEARCH
  • Home
  • 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 517131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:48:09+00:00 2026-05-13T07:48:09+00:00

OK I am just starting out with jQuery. I have a page with a

  • 0

OK I am just starting out with jQuery.

I have a page with a table of date-values. Each is wrapped in a tag which I can find with
$(‘mytag’).
<mytag>2009-10-31</mytag>

How, using Jquery, would I

  1. take each of the source values and
  2. pass it to a Javascript function
  3. then replace that source value within the table with the result of the function calculation.

So <mytag>2009-10-31</mytag>would be replaced with <mytag>Very Late</mytag>

I have the Javascript function written. My question is the jQuery syntax to pass the individual value.

  • 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-13T07:48:10+00:00Added an answer on May 13, 2026 at 7:48 am

    Firstly, you will need an element selector, e.g.

    $('table')
    

    Will select all <table> elements in your html. So,

    $('mytag')
    

    will give you your elements. You will get a jQuery object (not a DOM object) returned. See http://docs.jquery.com/Selectors

    Then you want to call a function for each of your elements. For this we call the .each function, and pass the function to call for each element:

    $('mytag').each(function(){
        //function code goes here
    });
    

    (See http://docs.jquery.com/Utilities/jQuery.each)

    The function in this case is called an Anonymous function

    Then you want to reference the current object in the iteration, so we use the DOM this item and wrap it into a jquery object. To get the value, we use the .text() function (http://docs.jquery.com/Attributes/text)

    $('mytag').each(function(){
        $(this).text()
    });
    

    Note: if it were an input element then you would have used .val()

    Passing it to a function is easy:

        ...
        MyFunction($(this).text());
        ...
    

    The text() function has an overloaded implementation which allows you to set the text if you pass a value:

        $(this).text(someval);
    

    So, we can factor this into our code

        ...
        $(this).text(MyFunction($(this).text()));
        ...
    

    Making our final code block:

    $('mytag').each(function(){
        $(this).text(MyFunction($(this).text()));
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just starting out using Lua, and I was wondering (because I can't find
I'm just starting out with JQuery in a Drupal environment. I have some thumbnails,
Just starting out with subversion, have set up repos for 3 current projects and
I am just starting out with writing jQuery plugins. I wrote three small plugins
I'm just starting out with JQuery. My Question: I want to know if I
Only just starting out with jQuery and I'm sure this is basic stuff for
Just starting out with LINQ to SQL (you can probably tell - be gentle).
I'm just starting out working with jQuery, so I'm using eclipse because it's what
Just starting out with canvas and javascript and can't get my head around why
Just starting out here, I have a Article.rb model that stores articles. So it

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.