console.log(jQuery("#tickets-expanded input:checkbox[name='ids[]']:checked"));
jQuery("#tickets-expanded input:checkbox[name='ids[]']:checked").each(function() {
selected.push(jQuery(this).val());
});
alert(selected);
jQuery("#ids").val(selected);
This is my code. Selected array contains elements in the format “2,1”. I want it to be [“2″,”1”]. What should I do?
Consider the code:
Output will be:
Now you can apply this technique on your code at the end. The string you are getting can be
splitand you will get the array.Edit: You have multiple
idelements? So you can alsosplitdata among them. Each will contain a value