I have an array in jQuery, and I’m using $.each() to loop through the array. I’m trying to find a way to compile a URL link using the values in the array
var selectArr = ["numbers123", "more_array_values", "etc", "more"];
$.each(selectArr,function(k,v){
k++;
alert('fid'+k+'='+v);
});
This works,
But I would like to somehow get it so it’ll be like
var url = fid1=numbers123&fid2=more_array_values&fid3=etc …
This way, I can use url and append it to a <a href=''>
Thanks!
Try this
Demo: Fiddle
You can clean up the answer by using the jQuery.map function as Felix said
I would recommend using that method over mine.