Return to Snippet

Revision: 28623
at August 6, 2010 04:31 by brandonjp


Updated Code
/**	v0.1 - 20081028 - thanks to Christian Oudard & Shog9 on StackOverflow - http://bit.ly/aqEKhO
	v0.2 - 201007100030 - brandonjp  **/

	
/**	specify an element, then collect the contents from each one on the page
	then concatenate all those contents and display them in one list/string  **/

// first, a variable for the element we want to collect
var theElements = $("td.fonta");

// second, a variable for the separater we want between each
// by default the 'join()' method returns comma separated values
var betweenEach = "";

// create the empty array where we'll store everything
var allCurries = [];

// now we actually get the elements we want and for each
theElements.each(function() {
	// grab our array and push each element's text() into it
	allCurries.push( $(this).text() );
});

// create a new object that joins everything in our array
var allTogether = allCurries.join(betweenEach);

// inject, print, show, alert or display our final list
$('div#output').replaceWith(allTogether);





/**	or the short version **/

var arr = [];
$('td').each(function() {
	arr.push($(this).text());
});
alert(arr.join(''));

Revision: 28622
at July 10, 2010 14:35 by brandonjp


Initial Code
/**	v0.1 - 20081028 - thanks to Christian Oudard & Shog9 on StackOverflow - http://bit.ly/aqEKhO
	v0.2 - 201007100030 - brandonjp  **/

	
/**	specify an element, then collect the contents from each one on the page
	then concatenate all those contents and display them in one list/string  **/

// first, a variable for the element we want to collect
var theElements = $("td.fonta");

// second, a variable for the separater we want between each
// by default the 'join()' method returns comma separated values
var betweenEach = "";

// create the empty array where we'll store everything
var allCurries = [];

// now we actually get the elements we want and for each
theElements.each(function() {
	// grab our array and push each element's text() into it
	allCurries.push( $(this).text() );
});

// create a new object that joins everything in our array
var allTogether = allCurries.join(betweenEach);

// inject, print, show, alert or display our final list
$('div#output').replaceWith(allTogether);





/**	or the short version **/

var arr = [];
$('td').each(function() {
	arr.push($(this).text());
});
alert(arr.join(''));





Initial URL

                                

Initial Description

                                

Initial Title
Use jQuery to collect join concatenate print display alert the contents value html text of each div li item span td cell in a pa

Initial Tags
js, list, textmate, jquery

Initial Language
jQuery