标签的标牌持有者

Placholder for tags

本文关键字:持有者 标签      更新时间:2023-09-26

是否可以为Select2标记控件设置占位符?

$(containerID).select2({
    multiple: true,
    tags: allTags,
    placeholderOption: "Tags"
});

用于select的placeholderOption可以正常工作,但对于标记没有影响。

我认为除了输入中的placeholder属性之外,您什么都不需要,比如:

<input type="hidden" id="select2-input" 
    placeholder="Tags placeholder" style="width:300px" />
<script>
    $("#select2-input").select2({
        tags: [],
    });
</script>

在select2()中执行此操作的替代方法,而不是使用内联HTML属性

$(containerID).select2({
    placeholder: "No tags yet, type here to tag",
    tags: [],
});