Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9198353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:15:46+00:00 2026-06-17T22:15:46+00:00

I am using jQuery dataTables to add new rows dynamically. I am able to

  • 0

I am using jQuery dataTables to add new rows dynamically. I am able to modify class attributes of the full row, but not columns therein.

In the below code I successfully set the css value to red and see the entire row with red font:

 var dataTableRow = ['c1', 'c2', 'c3', 'c4', 'c5', 'c6'];
 var newrow = $('#invoicetable').dataTable().fnAddData(dataTableRow);

 // set class attribute for the newly added row 
 var nTr = $('#invoicetable').dataTable().fnSettings().aoData[newrow[0]].nTr;

 // and parse the row:
 var nTds = $('td', nTr);


 nTds.attr('class', 'TMP');
 $('.TMP').css('color', 'red');

I recognize that nTds[] acts as an array containing columns of the row, but as simple a change as nTds[0].attr(‘class’, ‘TMP’); does not set just the 0th column to red font as I might expect.

Clearly I am missing something simple. Guidance appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:15:47+00:00Added an answer on June 17, 2026 at 10:15 pm

    nTds[0].attr() won’t work as attr is a jQuery method and nTds[0] returns the actual HTML element without the jQuery wrapper.

    If you want to target a single element using jQuery syntax you can use eq(), similar to this:

    nTds.eq(0).attr('class', 'TMP') //or 
    nTds.eq(0).addClass('TMP')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to jQuery dataTables and I'm overwhelmed. But now using it in a
I am using JQuery-DataTables-Editable-1.3 along with DataTables-1.9.4. I am able to add the add_delete_toolbar.
I am using jQuery dataTables version 1.9.2 Table is created with class datatable and
I'm using jQuery DataTables . This is my markup: <div class='wrapper'> <form> <table> <tr>
I am using jQuery datatables to display some data. Each row has an edit
I am using Datatables Collapsible/Expandable Grouping. http://jquery-datatables-row-grouping.googlecode.com/svn/trunk/collapsibleGroups.html I have configured it so that all
So I'm using the JQuery datatables.net(www.datatables.net) and having alot of success. But recently I
I'm trying to add a jQuery dialog in each row of a table, using
I'm really new at javascript and JQuery and I'm using JQuery datatables. I have
I am using jQuery Datatables plugin and I want to add some extra content

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.