搜索标记颜色
Search token color
我正在使用 bootstrap
搜索 field+tokeninput
。
我正在尝试获取不同颜色的令牌,并将 id
添加到每个令牌。
我正在使用这个 bootstrap 搜索字段:
<input type="text" id="exampleInlineTags" class="token-field" name="search" value="red, green" placeholder="enter text" />
和 boostrap tokeninput See the source for bootstrap-tokenfield
,一切正常,现在我需要在令牌输入上设置预定义颜色,就像这样:Example of what I am trying to achieve
编辑:更正了问题的语法,因为 OP 提到英语水平很差
如果您需要根据令牌的值分配特定的 ID 和颜色,那么您可以监听 tokenfield:createtoken 事件。
但是,如果您只需要为标记循环颜色,我建议您使用 CSS 来实现您的目标。要循环 10 种颜色的图案,您可以这样写:
.token:nth-of-type(10n+1){ ... }
.token:nth-of-type(10n+2){ ... }
...
.token:nth-of-type(10n+10){ ... }
我正在使用 bootstrap
搜索 field+tokeninput
。
我正在尝试获取不同颜色的令牌,并将 id
添加到每个令牌。
我正在使用这个 bootstrap 搜索字段:
<input type="text" id="exampleInlineTags" class="token-field" name="search" value="red, green" placeholder="enter text" />
和 boostrap tokeninput See the source for bootstrap-tokenfield ,一切正常,现在我需要在令牌输入上设置预定义颜色,就像这样:Example of what I am trying to achieve
编辑:更正了问题的语法,因为 OP 提到英语水平很差
如果您需要根据令牌的值分配特定的 ID 和颜色,那么您可以监听 tokenfield:createtoken 事件。
但是,如果您只需要为标记循环颜色,我建议您使用 CSS 来实现您的目标。要循环 10 种颜色的图案,您可以这样写:
.token:nth-of-type(10n+1){ ... }
.token:nth-of-type(10n+2){ ... }
...
.token:nth-of-type(10n+10){ ... }