这是重复控件的一部分,rIndex 是重复索引值。上面的代码工作正常,但我想在-6ren">
gpt4 book ai didi

html - 如何在计算文本字段中调用 HTML css 样式

转载 作者:太空宇宙 更新时间:2023-11-04 02:51:23 26 4
gpt4 key购买 nike

作为 Bootstrap 表的一部分,我有以下代码:

<xp:text escape="false"
id="tableRowstart" >
<xp:this.value><![CDATA[#{javascript:
if (rIndex % 2){
return "<tr style='background-color:#e6e6e6'><td>"
}else{
return "<tr style='background-color:#fbfbfb'><td>"}}]]></xp:this.value>
</xp:text>

这是重复控件的一部分,rIndex 是重复索引值。上面的代码工作正常,但我想在 css 中使用它。所以我将这些行添加到我的 CSS 中:

.oddLineBackground {background-color:#e6e6e6 ;}
.evenLineBackground {background-color:#fbfbfb ;}

如果我修改我的代码以使用 css 如下:

<xp:text escape="false"
id="tableRowstart" >
<xp:this.value><![CDATA[#{javascript:
if (rIndex % 2){
return "<tr style='oddLineBackground'><td>"
}else{
return "<tr style='evenLineBackground'><td>"}}]]></xp:this.value>
</xp:text>

线条颜色不会改变,它们显示时没有应用任何样式。我可以将 oddLineBackground 和 evenLineBackground 应用于面板或 ???直接来自样式选择器,它们显示正确,但是当我计算它们时,它们似乎计算不正确。我猜这是我的语法中的某些东西,但无法弄清楚。

最佳答案

改变:

<tr style='oddLineBackground'>

为此:

<tr class='oddLineBackground'>

关于html - 如何在计算文本字段中调用 HTML css 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32926682/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com