var arr = ['one','two','three','four','five'];
$.each(arr, function(index, value){
console.log('The value at arr[' + index + '] is: ' + value);
});
var listItems = $("#productList li");
listItems.each(function(idx, li) {
var product = $(li);
// and the rest of your code
});
// Generic Jquery Loop
var i;
for (i = 0; i < substr.length; ++i) {
// do something with `substr[i]`
}
@model StudentSearchResult
<script type="text/javascript">
var students = @Html.Raw(Json.Encode(Model.Students));
// students is a javascript array that will look like this:
// students = [{"FirstName":"fn1","LastName":"ln1"}, {"FirstName":"fn2","LastName":"ln2"}, ...];
for (var i = 0; i < students.length; i++) {
var student = students[i];
alert('FirstName: ' + student.FirstName + ' LastName:' + student.LastName);
}
</script>