I`m working on an interactive story using Jquery. My question is; I want to change the text everytime I click in a button to the next dialogue function, so I created an object with some functions that contains the dialogues. Since it's an object, not an array, how can I access it's elements by click count?
story ={
dialogue: function(){
$("p").text("My name is Richard");
},
dialogue: function(){
$('p').text("Nice to meet you!").hide().fadeIn(1000);
},
dialogue: function(){
$('p').text("what is your name").hide().fadeIn(1000);
}
};
var clickCount = 0;
var nextStatment = function() {
$('p').text(story[clickCount]).hide().fadeIn(1000);
clickCount++;
};
$('.slideBt1').on('click', nextStatment);