grab column elements from table header

beebek

I have a table which has a search field. After searching data, the listed data are to be exported into excel which requires some extra information to be added which is not shown in the table, needs to be pulled from database. So, I need to access all the listed data's id (after seraching). Also the tag has no relevant 'id' or 'class' so that it can be grabbed, since it were rendered using datatables. How can this be achieved using jquery

code snippet

<table id='mytable' border='1'>
    <tr>
        <th id='ID'>ID</th>
        <th id='Email'>Email</th>
    </tr>
    <tr>
        <td>1</td>
        <td>[email protected]</td>
    </tr>
    <tr>
        <td>2</td>
        <td>[email protected]</td>
    </tr>
    <tr>
        <td>3</td>
        <td>[email protected]</td>
    </tr>
</table>

<button id='gen'>Generate excel file</button>

jsfiddle: http://jsfiddle.net/xLA3g/2/

caramba

have a look at this, may it helps http://jsfiddle.net/xLA3g/3/

$('#mytable tr th').each(function(i){
    alert($(this).text());
});

ANSWER UPDATE, show td column number http://jsfiddle.net/xLA3g/4/

$('#mytable tr td:first-child').each(function(i){
    alert($(this).text());
});

let me know if I can help assist any further

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to grab all tr elements from a table and click on a link?

From Dev

Grab from table values

From Dev

SQL SELECT from TABLE B based on column but grab all rows based on TABLE A ID

From Dev

Grab one row from a table

From Dev

Making a pivot table from a table with header cells in the first column

From Dev

Grab values of an attribute from all elements in jQuery

From Dev

How to grab a column from a web browser

From Dev

Grab inner text from HTML that isn't from a header

From Dev

Grab table from URL in Google App Script

From Dev

Grab Data on the Fly from Table HTML

From Dev

Selenium Python how to locate a specified row and a column from a table of elements

From Dev

R data.table Accessing elements from a column of lists

From Dev

Row header and column header for a particular cell in table

From Dev

Avoid Repeating Column Header in Table

From Dev

Put a component in a table column header?

From Dev

What is the proper way to grab Authorization header from controller request object?

From Dev

Reference a table column by its column header in Python

From Dev

Hover over table column, row AND header column

From Dev

Sticky header of table with sticky table column

From Dev

How to grab Image url and title from elements above in same article

From Dev

Removing column header from output

From Dev

How do I transpose a table in Pentaho Kettle from rows to columns without the header column

From Dev

Grab matching column from text file in python list

From Dev

Grab one specific column from multiple csv files and merge into one

From Dev

Table from SQL query with header

From Dev

Grab value from another table via foreign key

From Dev

How to grab multiple rows from a table with the same value for a foreign key

From Dev

MYSQL and PHP loop and grab just one item from a joint table?

From Dev

How do I grab the most recent price change from table

Related Related

  1. 1

    How to grab all tr elements from a table and click on a link?

  2. 2

    Grab from table values

  3. 3

    SQL SELECT from TABLE B based on column but grab all rows based on TABLE A ID

  4. 4

    Grab one row from a table

  5. 5

    Making a pivot table from a table with header cells in the first column

  6. 6

    Grab values of an attribute from all elements in jQuery

  7. 7

    How to grab a column from a web browser

  8. 8

    Grab inner text from HTML that isn't from a header

  9. 9

    Grab table from URL in Google App Script

  10. 10

    Grab Data on the Fly from Table HTML

  11. 11

    Selenium Python how to locate a specified row and a column from a table of elements

  12. 12

    R data.table Accessing elements from a column of lists

  13. 13

    Row header and column header for a particular cell in table

  14. 14

    Avoid Repeating Column Header in Table

  15. 15

    Put a component in a table column header?

  16. 16

    What is the proper way to grab Authorization header from controller request object?

  17. 17

    Reference a table column by its column header in Python

  18. 18

    Hover over table column, row AND header column

  19. 19

    Sticky header of table with sticky table column

  20. 20

    How to grab Image url and title from elements above in same article

  21. 21

    Removing column header from output

  22. 22

    How do I transpose a table in Pentaho Kettle from rows to columns without the header column

  23. 23

    Grab matching column from text file in python list

  24. 24

    Grab one specific column from multiple csv files and merge into one

  25. 25

    Table from SQL query with header

  26. 26

    Grab value from another table via foreign key

  27. 27

    How to grab multiple rows from a table with the same value for a foreign key

  28. 28

    MYSQL and PHP loop and grab just one item from a joint table?

  29. 29

    How do I grab the most recent price change from table

HotTag

Archive