looping array/structure in jquery or in javascript. here is simple code from jquery.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>
//array
var mykids = new Array();
mykids[0]="kid1";
mykids[1]="kid2";
mykids[2]="kid3";
$.each(mykids, function(index, value) {
alert(index + ': ' + value);
});
/structure
var map = {
'key 1': 'val1',
'key 2': 'val2'
};
$.each(map, function(key, value) {
alert(key + ': ' + value);
});
</script>
var mykids = new Array();
mykids[0]="kid1";
mykids[1]="kid2";
mykids[2]="kid3";
$.each(mykids, function(index, value) {
alert(index + ': ' + value);
});
/structure
var map = {
'key 1': 'val1',
'key 2': 'val2'
};
$.each(map, function(key, value) {
alert(key + ': ' + value);
});
</script>
No comments:
Post a Comment