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(","));
});
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn