I have this code
<script type="text/javascript">
var slideStart = 1;
var slideCount = 4;
function callArr() {
var arrName = {"rose":"5", "daisy":"4",
"orchid":"3", "sunFlower":"10",
"Lily":"15"};
for (var flwr in arrName) {
if (slideStart <= slideCount) {
document.getElementById('test').innerHTML += flwr +
" >>>>>>>> " +
arrName[flwr] +
"<br />";
slideStart++;
break;
}
}
}
</script>
I want to access array elements individually on any event. can any please help me out on this????
Of course it will print only the first element since you use condition like this
Modify your code to iterate through the object properties. One of the possible solutions:
Try it here: http://jsfiddle.net/2nDv8/
As you can see, it prints the next property after every call.