HTML - if else 条件 "if selection contains X, do Y"
HTML - if else with conditional "if selection contains X, do Y"
抱歉这个基本问题。我只是根本不使用 HTML,所以我真的不能自己解析它。
基本位是我有一个定性问题被编程为循环和合并,但我需要根据从循环和合并中提取的数据对文本进行颜色编码。
基本示例是说我有这三对字段:
Field 1 Field 2
50% up 50% up
50% down 50% up
50% up No change
如果提取的数据是 "up," 如果 "down," 是红色,如果 "no change."
是黄色,我需要问题中填充的文本是绿色的
因此,问题文本如下所示:
Imagine a new economic policy was proposed that was projected to:
- result in a ${lm://Field/1} of the wealth of the country's poor
- result in a ${lm://Field/2} of the wealth of the country's rich
Would you vote for this policy?
随机成对拉取字段的位置。 如何将此处的 HTML 编辑为“如果字段 1 包含单词 [up/down/no 更改”,为文本着色 [green/red/yellow];如果字段 2 包含单词 [up/down/no change],请为文本着色 [green/red/yellow]?
作为参考,这里是HTML,因为它已经存在于问题中:
Imagine a new economic policy was proposed that was projected to:
<div><br>
- result in a<span style="color: rgb(39, 174, 96);"> </span><strong>${lm://Field/1} </strong>of the wealth of the country's <span style="font-weight: 700;">poor</span> <br>
- result in a <strong>${lm://Field/2}</strong> of the wealth of the country's <span style="font-weight: 700;">rich</span> </div>
<div><br>
Would you vote for this policy?</div>
如有任何指导,我们将不胜感激!
您需要将颜色包含为循环和合并字段。为了尽量减少更改,假设 field3 是 field1 的颜色,field4 是 field2 的颜色。
您的循环和合并字段将是:
Field 1 Field 2 Field 3 Field4
50% up 50% up green green
50% down 50% up red green
50% up No change green yellow
(如果需要,您也可以使用十六进制或 rgb 颜色代码)
那么你的 html 会是这样的:
Imagine a new economic policy was proposed that was projected to:
<ul>
<li>result in a <span style="color:${lm://Field/3};font-weight:bold">${lm://Field/1}</span> of the wealth of the country' s poor</li>
<li>result in a <span style="color:${lm://Field/4};font-weight:bold">${lm://Field/2}</span> of the wealth of the country's rich</li>
</ul>
Would you vote for this policy?
抱歉这个基本问题。我只是根本不使用 HTML,所以我真的不能自己解析它。
基本位是我有一个定性问题被编程为循环和合并,但我需要根据从循环和合并中提取的数据对文本进行颜色编码。
基本示例是说我有这三对字段:
Field 1 Field 2
50% up 50% up
50% down 50% up
50% up No change
如果提取的数据是 "up," 如果 "down," 是红色,如果 "no change."
是黄色,我需要问题中填充的文本是绿色的因此,问题文本如下所示:
Imagine a new economic policy was proposed that was projected to:
- result in a ${lm://Field/1} of the wealth of the country's poor
- result in a ${lm://Field/2} of the wealth of the country's rich
Would you vote for this policy?
随机成对拉取字段的位置。 如何将此处的 HTML 编辑为“如果字段 1 包含单词 [up/down/no 更改”,为文本着色 [green/red/yellow];如果字段 2 包含单词 [up/down/no change],请为文本着色 [green/red/yellow]?
作为参考,这里是HTML,因为它已经存在于问题中:
Imagine a new economic policy was proposed that was projected to:
<div><br>
- result in a<span style="color: rgb(39, 174, 96);"> </span><strong>${lm://Field/1} </strong>of the wealth of the country's <span style="font-weight: 700;">poor</span> <br>
- result in a <strong>${lm://Field/2}</strong> of the wealth of the country's <span style="font-weight: 700;">rich</span> </div>
<div><br>
Would you vote for this policy?</div>
如有任何指导,我们将不胜感激!
您需要将颜色包含为循环和合并字段。为了尽量减少更改,假设 field3 是 field1 的颜色,field4 是 field2 的颜色。
您的循环和合并字段将是:
Field 1 Field 2 Field 3 Field4
50% up 50% up green green
50% down 50% up red green
50% up No change green yellow
(如果需要,您也可以使用十六进制或 rgb 颜色代码)
那么你的 html 会是这样的:
Imagine a new economic policy was proposed that was projected to:
<ul>
<li>result in a <span style="color:${lm://Field/3};font-weight:bold">${lm://Field/1}</span> of the wealth of the country' s poor</li>
<li>result in a <span style="color:${lm://Field/4};font-weight:bold">${lm://Field/2}</span> of the wealth of the country's rich</li>
</ul>
Would you vote for this policy?