Can anyone explain me how to do this, jquery’s api is really lacking on this. What is wrong in the following code?
var arr = $(value).filter(function() { return $(this).is("TD"); } ).html();
alert(arr[1]);
I just want to grab the innerHTML/text of the td and put it in an array
Using
.map()with.get()is one way to go:I’m not sure what
valuerepresents, but if you change the selector to match onlytdelements, you could simplify the return statement withreturn $(this).html();..map()iterates over the elements, and adds the return value to the jQuery object..get()retrieves just the array out of the jQuery object.Sounds like
valueis atr. Then you could do this:To create an array with each item containing an array of that row’s
tdelement’s html, you could do this:This uses the standard
.push()since I don’t think that using.map()inside.map()would work. I think when you pass the inner array into the jQuery object, it just adds it to the main array (or something).