After checking, jquery has no direct method,
, but there is a map method, which is very simple to define a method to implement this function
jQuery.fn.join = function(sep,mapvalue){
return $.map(this,mapvalue).join (sep);
};
jQuery.fn.joinattr = function(sep,attr){
return this.join(sep,function(item){return $(item).attr(attr) ;});
};
jQuery.fn.joinvalue = function(sep){
return this.join(sep,function(item){return $(item).val();}) ;
};
When using
$("#getid").click(function(){
alert($("input").joinattr(",","id"));
});
$("#getvalue").click(function(){
alert($("input").joinvalue(","));
});