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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:17:34+00:00 2026-05-14T04:17:34+00:00

I am trying to write a simple piece of Jquery in which the script

  • 0

I am trying to write a simple piece of Jquery in which the script will check whether a table cell contains a range of numbers.

I’m unsure how to do this, because if you were to do something like this:

var num_range = ">1";
$("td:contains(" + num_range + ")").css('background-color', '#000');

…the script only detects if the td contains the exact text “>1”, rather than what I’m after, it detecting whether any tds contain any numbers greater than 1. (Any then styling the background)

Thanks for any help, I’m a Javascript/Jquery novice!

  • 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-14T04:17:34+00:00Added an answer on May 14, 2026 at 4:17 am

    There’s no native jQuery selector for this. You could write one if you want or just use:

    $("td").each(function() {
      if (parseInt($(this).text()) > 1) {
        $(this).css("background", "#000");
      }
    });
    

    If you want to create your own selector:

    $.extend($.expr[":"], {
      expr: (function() {
        var op = {
          '=': function(n1, n2) { return n1 == n2; },
          '!=': function(n1, n2) { return n1 != n2; },
          '>': function(n1, n2) { return n1 > n2; },
          '>=': function(n1, n2) { return n1 >= n2; },
          '<': function(n1, n2) { return n1 < n2; },
          '<=': function(n1, n2) { return n1 <= n2; }
        };
        var ops = [];
        for (p in op) {
          ops.push(p);
        }
        var r = new RegExp("^\\s*(" + ops.join("|") + ")\\s*(-?\\d+(?:\\.\\d+)?)\\s*$");
        return function(elem, i, match) {
          var m = r.exec(match[3]);
          return m && op[m[1]](parseFloat($(elem).text()), parseFloat(m[2]));
        };
      })()
    });
    

    And then you can do:

    $("td:expr(>5)").css("background", "yellow");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write some simple code which will read a text file
Am trying to write a piece of code which will allows the user to
I'm trying to write up a simple jquery script that parses some JSON and
Hi I'm trying to write a piece of code for a simple verification method
I am trying to write a simple Java function that will take a list
I'm trying to write a bash script that will download all of the youtube
I'm trying to write a simple ruby script to update my GIT working directories.
I am trying to write a very simple piece of code to create a
I'm trying to write a regex to parse a (seemingly very simple) piece of
I'm trying to write a very simple piece of code and can't figure out

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.