I'm using a mixture of d3.js and jQuery to create a visualisation. I have 3 functions that I'm trying to put into an array and then execute one after the other but I don't think I'm doing it correctly as when I click "play" nothing happens. Here's my code:
var functionsArray = [oct12,oct13,oct14];
$('#play').click(function(){
for (var i = 0; i < functionsArray.length; i++){
functionsArray[i];
}
I'll put up a jsfiddle shortly...
You need to call the function too.
functionsArray[i]();
use $.each
demo
var functionsArray = [oct12,oct13,oct14];
$(functionsArray).each(function(key, val){
val();
});
function oct12(){
alert('oct12');
}
function oct13(){
alert('oct13');
}
function oct14(){
alert('oct14');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With