开发者

Building a decision-making game in jQuery? Where would I store data

I built a slideshow/decision-making game in Flash but would like to try to redo it using jQuery.

The slideshow part seems simple enough, however I have a series of user decisions that I'm not sure how to approach.

In flash, if the user makes a decision, I would just store this in a variable or shared 开发者_运维知识库local objects, is this the same for jQuery? i.e. mix regular javascript variables with the jQuery?


You can store it in a object, as easy as:

var myDecisions = {};

Or an array: var myDecisions = [];

Or on the element itself if it's related to an element with jQuery like this:

$('#thing5').data("decision", "good decision"); //Set
var decision = $('#thing5').data("decision"); //Get


store it in a closure, or a global variable.

regular javascript variables are no different then jquery variables. its all javascript.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜