0

Basically what the title says... just having trouble getting it to work and couldn't find a solution online.

Code:

    var arr=new Array();
    $('#tableC tr').each(function() {
        var tr = $(this);
        tr.find('td').each(arr, function() {
            $(this).val();
        });
    });
1
  • Indeed. @Slaks♦ is correct. Use .text() instead. Commented Aug 3, 2011 at 18:43

3 Answers 3

2

Try this

var arr = [];
    $('#tableC td').each(function() {
        arr.push($(this).text());
    });
Sign up to request clarification or add additional context in comments.

Comments

2

You're completely miscalling each.

Instead, write

tr.find('td').each(function() {
    arr.push($(this).val());
});

You could also write

var arr = $("#tableC tr td").map(function() { return $(this).val(); }).get();

1 Comment

arr.append ? What are you using Chrome v18 with support for ECMAScript 7th edition? ;o)
0

Something along these lines?

http://jsfiddle.net/pPxcE/

Edit

code

var arr=new Array();
$('#tableC tr').each(function() {
    var tr = $(this);
    tr.find('td').each(function() {
        arr.push($(this).text());
    });
});

5 Comments

I didn't down vote you, but it may be because you posted a link to another site in lieu of the actual code for your solution.
Please put more than just a link in your answer. In particular, you should include the code here.
everyone does... that's what fiddles are for. I've never gotten a downvote for using jsfiddle... posters are even told to use the site to help us answer their questions.
@Joseph: StackOverflow is intended to be an independent repository of questions and answers. Sometimes jsFiddle is down (or extremely slow), making your answer useless at those times to future readers. I'll +1 for your solution, and for the update. :o)
@patrickdw Thank you, patrick. I'll use it as strictly supplementary from now on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.