var pieceSize = new Array();
pieceSize[0] = 200;
pieceSize[1] = 400;
pieceSize[2] = 300;
THIS DOESN’T WORK:
$("#visual").animate({
height: pieceSize[this.id.slice(5, 6)]
}, 250, function() {
});
BUT THIS DOES:
$("#visual").animate({
height: pieceSize[2]
}, 250, function() {
});
LOG:
this.id.slice(5, 6) == 0 or 1 or 2 (i’m slicing the id of the button being clicked)
I’ve tried different combinations adding parseInt and none of it works:
height: pieceSize[parseInt(this.id.slice(5, 6))])
height: parseInt(pieceSize[this.id.slice(5, 6)])
height: parseInt(parseInt(pieceSize[this.id.slice(5, 6)]))
This is just working: JsFiddle
What is in the log if you echo
pieceSize[this.id.slice(5, 6)]?