gpt4 book ai didi

javascript - 搜索标记颜色

转载 作者:行者123 更新时间:2023-11-28 16:13:01 25 4
gpt4 key购买 nike

我正在使用 bootstrap 搜索 field+tokeninput

我正在尝试获取不同颜色的 token ,并将 id 添加到每个 token 。

我正在使用这个 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,一切正常,现在我需要在 token 输入上设置预定义颜色,就像这样:Example of what I am trying to achieve

编辑:更正了问题的语法,因为 OP 提到英语水平很差

最佳答案

如果您需要根据 token 的值分配特定的 ID 和颜色,那么您可以监听 tokenfield:createtoken 事件。

但是,如果您只需要为标记循环颜色,我建议您使用 CSS 来实现您的目标。要循环 10 种颜色的图案,您可以这样写:

.token:nth-of-type(10n+1){ ... }

.token:nth-of-type(10n+2){ ... }

...

.token:nth-of-type(10n+10){ ... }

关于javascript - 搜索标记颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38052182/

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