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 4235666
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:31:52+00:00 2026-05-21T02:31:52+00:00

i am trying to change the background color of a jquery datatable based on

  • 0

i am trying to change the background color of a jquery datatable based on a date range….i tried to use $.fn.afnFiltering.push(…) to do the date range filtering…but cant figure out how to change the color of the filtered rows….

heres the code i am using to do the filtering…i tested this and the date range filtering works…

        //row filtering by date
$.fn.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
    var iFini = document.getElementById('dateStart').value;
    var iFfin = document.getElementById('dateEnd').value;
    if (iFini == "" && iFfin == "") {
        return true;
    }
    else if (iFini != "" && iFfin == "") {
        return true;
    }
    else if (iFini == "" && iFfin != "") {
        return true;
    }
    else if (iFini != "" && iFfin != "") {
        var sdate = new Date();
        var edate = new Date();
        var initialdt = iFini.split("/");
        var enddt = iFfin.split("/");
        var filterdt1 = aData[3].split(" ");
        var filterdt = filterdt1[0].split("/");
        var msg = "";
        if ((Number.parseInvariant(filterdt[0]) + 1 >= Number.parseInvariant(initialdt[0]) + 1 && Number.parseInvariant(filterdt[0]) + 1 <= Number.parseInvariant(enddt[0]) + 1) && (Number.parseInvariant(filterdt[1]) >= Number.parseInvariant(initialdt[1]) && Number.parseInvariant(filterdt[1]) <= Number.parseInvariant(enddt[1])) && (Number.parseInvariant(filterdt[2]) >= Number.parseInvariant(initialdt[2]) && Number.parseInvariant(filterdt[2]) <= Number.parseInvariant(enddt[2]))) {
            // msg = "initialdt: " + initialdt[0] + "/" + initialdt[1] + "/" + initialdt[2] + "====" + "enddt: " + enddt[0] + "/" + enddt[1] + "/" + enddt[2] + "====Filter:" + filterdt[0] + "/" + filterdt[1] + "/" + filterdt[2] + "/n";

                //need to change the style here...not sure how to address        
                //the individual row

            return true;
        }
    }

    return true;
}
);

i am also binding the fnDraw function as below…

 $("#dateStart").keyup(function () { $dTable.fnDraw(); });
 $("#dateStart").change(function () { $dTable.fnDraw(); });
 $("#dateEnd").keyup(function () { $dTable.fnDraw(); });
 $("#dateEnd").change(function () { $dTable.fnDraw(); });
  • 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-05-21T02:31:53+00:00Added an answer on May 21, 2026 at 2:31 am

    You can get the tr element using iDataIndex and fnGetNodes.


    var tr = oTable.fnGetNodes(iDataIndex);
    $(tr).css('background-color', '#F00');

    oTable must contain the dataTable object.


    var oTable = $("#myTable").dataTable({ ... });

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to animate background-color,color and border color to change with jquery but for
I am trying to change the menuOption background-color on hover using JQuery. All my
I'm trying to change the background color of single cell be based on a
I have the following jQuery that I'm trying to use to change the background
Using JQuery's jquery.animate-colors-min.js plugin I am trying to change the background color of some
I'm trying to change the background color of a single subplot in a MATLAB
I am trying to change the Background Color of the ParentGrid when the child
I am trying to change the color on text on hover using Jquery. I
I am trying to change the background color of a td element in a
What I'm trying to do is to change the background color on the whole

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.