I have a hidden input box from which I\'m retrieving the comma-separated text value (e.g. \'apple,banana,jam\'
) using:
var searchTerms = $(\"#se
use js split() method to create an array
var keywords = $('#searchKeywords').val().split(",");
then loop through the array using jQuery.each() function. as the documentation says:
In the case of an array, the callback is passed an array index and a corresponding array value each time
$.each(keywords, function(i, keyword){
console.log(keyword);
});