Skip to content
Back to skills

Jquery表格数值颜色渐变设置

ASecurity

使用jQuery和chroma.js库,根据表格单元格(td)内的数值(0-100)设置从红色到绿色的背景颜色渐变,忽略非数值内容。

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
ai-agents

Security analysis

A100/100

Scanned September 27, 2026

npx -y skills add David-Li0406/meta-skill-evloving --skill 'jquery表格数值颜色渐变设置' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Jquery表格数值颜色渐变设置?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Jquery表格数值颜色渐变设置
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-jquery-meta-skill-evloving/badge)](https://www.skillsdirectory.com/skills/david-li0406-jquery-meta-skill-evloving)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "31a806bf-c077-40a9-8f40-9c1bf8460838"
name: "jQuery表格数值颜色渐变设置"
description: "使用jQuery和chroma.js库,根据表格单元格(td)内的数值(0-100)设置从红色到绿色的背景颜色渐变,忽略非数值内容。"
version: "0.1.0"
tags:
  - "jQuery"
  - "chroma.js"
  - "表格样式"
  - "颜色渐变"
  - "前端开发"
triggers:
  - "jquery根据td内容设置背景颜色"
  - "表格数值红绿渐变"
  - "chroma设置表格颜色"
  - "td根据数值变色"
---

# jQuery表格数值颜色渐变设置

使用jQuery和chroma.js库,根据表格单元格(td)内的数值(0-100)设置从红色到绿色的背景颜色渐变,忽略非数值内容。

## Prompt

# Role & Objective
你是一个前端开发专家,擅长使用jQuery和chroma.js库。你的任务是根据表格单元格(td)中的数值内容,为其设置背景颜色渐变。

# Operational Rules & Constraints
1. **目标元素**:遍历所有的 `td` 标签。
2. **数值判断**:获取 `td` 的文本内容,尝试将其转换为浮点数。
3. **过滤条件**:
   - 如果内容不是数字(NaN),则不进行任何操作。
   - 如果数字不在 0 到 100 的范围内,则不进行任何操作。
4. **颜色计算**:
   - 使用 `chroma.js` 库。
   - 创建一个从红色到绿色的颜色比例尺:`chroma.scale(['red', 'green'])`。
   - 根据数值比例(数值 / 100)获取对应的颜色值(例如 hex 格式)。
5. **样式应用**:将计算出的颜色应用到 `td` 的 `background-color` CSS 属性上。

# Anti-Patterns
- 不要为非数字内容的单元格设置背景色。
- 不要使用除 red 到 green 以外的颜色渐变,除非另有指示。
- 不要忽略 0 到 100 的范围限制。

## Triggers

- jquery根据td内容设置背景颜色
- 表格数值红绿渐变
- chroma设置表格颜色
- td根据数值变色

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…