i have a string which is coming as 1,2,3,4,5,6
i want thee string to be as: id=1&id=2&id=3&id=4&id=5&id=6
as in jquery, how can i modift the string like tis: the value i am getting is from the array as like this, i need to pass it to my href link so i can use it on my next page
var arr = [];
$('input[class="allchecks"]:checked').each(function() {
arr.push($(this).val());
});
alert(arr);
$('input[class="allchecks"]:checked').map(function(id) {
return 'id=' + $(this).val();
}).join('&');
尝试使用数组连接方法:
arr.join('&');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.