How to bind the data to array as comma separated data in jquery
I have an array which stores the values and using those values in the array i am fetching the text of that value by using a loop.I need to bind the text in second array in comma separated
Below is the code i used
var secondarray = [];
for (var i = 0; i < firstarray.length; i++) {
text = $('input.class[value = "' + firstarray[i] + '"]').attr("text");
if (text != "" && text != undefined) {
secondarray += secondarray .push(text);
alert(secondarray); //here if i have 3 values in first array i need to display corresponding text as chk1,chk2,chk3
}
}
["40257", "40311", "40532", "40263"]
<input type="checkbox" name="Type" class="cls" value="40263" text="apple">
<input type="checkbox" name="Type" class="cls" value="40532" text="ball">
<input type="checkbox" name="Type" class="cls" value="40311" text="bat">
<input type="checkbox" name="Type" class="cls" value="40257" text="mat">