我正在使用 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/