0

I need to add names to each td in table. Like this.

<table>
    <tbody>
        <tr>
            <td name="Name">#Value#</td>
            <td name="Type">#Value#</td>
            <td name="Price">#Value#</td>
        </tr>
        ....
    </tbody>
</table>

So generally I want all columns to have names. This is what I browsed through and still can't really "put my finger" on it. DataTables forum post, how to add class to jquery.datatables columns?

4
  • Could you please explain clearly, what you want to do? Commented Dec 4, 2013 at 15:20
  • I clearly explained it. I want to add a name to a TD with DataTables plugin. Commented Dec 4, 2013 at 15:25
  • @rexdefuror Whatever you are trying to achieve can be done by assigning id to your columns or you can assign id to your table. Is it feasible for your solution? Commented Dec 4, 2013 at 15:25
  • Unfortunately it HAS to be name attribute. Commented Dec 4, 2013 at 15:26

1 Answer 1

0

Assign Id to your td fetch that and assign it name attribute .

 <tr>
     <td id="tdFirst" >#Value#</td>

 </tr>

 var nTds = $('#tdFirst').attr('name', "WhateverNameYouWant");   

It's not a very good solution but see if it works for you.

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah I thought of that as well, but trying to find some more eligible solution if possible. Thanks though.
@rexdefuror If your columns and their names are constant throughout whole table (or rows), You can select whole table and loop through it assigning names using this api.jquery.com/eq

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.