//剔除多余的逗号 function checkMulReaders(item) { var name = g(item), nArray = name.split(","), nValue = ""; for (var i = 0, len = nArray.length; i < len; i++) { if (nArray[i].replace(/(^s+)|(s+$)/g,"") != "") { nValue == "" ? nValue = nArray[i] : nValue += "," + nArray[i]; } } s(item, nValue); } //jQuery剔除多余的逗号 (function($) { $.fn.checkUser = function (){ function checkMulReaders(item){ var name = g(item), nArray = name.split(","), nValue = ""; for (var i = 0, len = nArray.length; i < len; i++) nArray[i].replace(/(^s+)|(s+$)/g, "") != "" && (nValue = nValue == "" ? nArray[i] : nValue + "," + nArray[i]); s(item, nValue); } this.each(function(){ checkMulReaders(this.name); }); }; })(jQuery);