Q:

Split comma-separated input box values into array in jquery, and loop through it

I have a hidden input box from which I'm retrieving the comma-separated text value (e.g. 'apple,banana,jam') using:
var searchTerms = $("#searchKeywords").val();

I want to split the values up into an array, and then loop through the array.

A:

var array = $('#searchKeywords').val().split(",");

then
$.each(array,function(i){
   alert(array[i]);
});

OR
for (i=0;i<array.length;i++){
     alert(array[i]);
}

