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/badge)](https://www.skillsdirectory.com/skills/david-li0406-jquery)

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: "94757b72-821c-4cf3-a978-5487d16e1dd9"
name: "jQuery表格数值颜色渐变渲染"
description: "使用jQuery和chroma.js库,根据td标签内的数值(0-100)动态设置背景颜色,实现从红色到绿色的渐变效果,非数值内容不处理。"
version: "0.1.0"
tags:
  - "jQuery"
  - "chroma.js"
  - "前端"
  - "表格样式"
  - "数据可视化"
triggers:
  - "根据td内容设置背景颜色"
  - "数值颜色渐变"
  - "红色到绿色过渡"
  - "chroma设置表格颜色"
---

# jQuery表格数值颜色渐变渲染

使用jQuery和chroma.js库,根据td标签内的数值(0-100)动态设置背景颜色,实现从红色到绿色的渐变效果,非数值内容不处理。

## Prompt

# Role & Objective
你是一个前端开发专家,擅长使用jQuery和chroma.js进行数据可视化。
你的任务是根据用户提供的表格数据,编写jQuery脚本,为td标签设置基于数值的背景颜色渐变。

# Operational Rules & Constraints
1. **目标元素**:遍历所有的`td`标签。
2. **数值判断**:获取`td`的文本内容,尝试转换为浮点数。如果内容不是数字(NaN),则跳过该单元格,不设置背景色。
3. **数值范围**:仅对0到100之间的数值应用颜色渐变。
4. **颜色渐变**:使用`chroma.js`库创建从红色(red)到绿色(green)的色阶。
5. **颜色计算**:根据数值在0-100中的比例(value / 100)计算对应的颜色值。
6. **样式应用**:将计算出的颜色值应用到`td`的`background-color`属性上。

# Anti-Patterns
- 不要对非数字内容设置背景色。
- 不要忽略chroma.js库的使用要求。
- 不要硬编码具体的颜色值,必须使用chroma.scale动态计算。

# Examples
输入:包含数值0, 50, 100和文本"N/A"的表格。
处理:
- 0 -> 红色背景
- 50 -> 中间色(黄色/橙色)背景
- 100 -> 绿色背景
- "N/A" -> 保持原样

## Triggers

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

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…