First, you will need an element selector like
$('table')
Will select all <table> elements in your html. Thus,
$('mytag')
will provide you with your items. You will get a jQuery object (not a DOM object). See http://docs.jquery.com/Selectors
Then you want to call a function for each of your elements. To do this, we call the .each function and pass the function to call for each element:
$('mytag').each(function(){
(see http://docs.jquery.com/Utilities/jQuery.each )
The function in this case is called the Anonymous>
Then you want to reference the current object in iteration, so we use the DOM this element and transfer it to the 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, you would use .val ()
Passing it to a function is simple:
... MyFunction($(this).text()); ...
The text () function has an overloaded implementation that allows you to set text if you pass in a value:
$(this).text(someval);
So we can do it in our code
... $(this).text(MyFunction($(this).text())); ...
Creating our final code:
$('mytag').each(function(){ $(this).text(MyFunction($(this).text())); });