将逗号添加到jquery中的结果值

时间:2014-03-14 07:26:37

标签: javascript php jquery

如果我在jquery中有这个代码,如何添加逗号(,):

var title = !this.multiple ? selectedItems[0] : selectedItems.join(", ");

            //If this is multi select, and the selectText type is count, the show 1 of 2 selected etc..
            if (this.multiple && this.options.selectedTextFormat.indexOf('count') > -1) {
                var max = this.options.selectedTextFormat.split(">");
                var notDisabled = this.options.hideDisabled ? ':not([disabled])' : '';
                if ( (max.length>1 && selectedItems.length > max[1]) || (max.length==1 && selectedItems.length>=2)) {
                    title = this.options.countSelectedText.replace('{0}', selectedItems.length).replace('{1}', this.$element.find('option:not([data-divider="true"]):not([data-hidden="true"])'+notDisabled).length);
                }
             }

            //If we dont have a title, then use the default, or if nothing is set at all, use the not selected text
            if (!title) {
                title = this.options.title != undefined ? this.options.title : this.options.noneSelectedText;
            }

            this.$newElement.find('.filter-option').html(title);

dropdown我选择了多个值,它们将按(,)这样加入:'Compositor,Designer,Graphic Artist'但是当我得到值并将其发布在上面的表中时,值变为'CompositorDesignerGraphicArtics'

在jquery代码中如何插入逗号。因此,当我得到值时,它应该与下拉列表中的相同。

0 个答案:

没有答案