var test1;
$(document).ready(function () {
test1 = $("#test1ID").jQueryPlugin();
});
var test2;
$(document).ready(function () {
test2 = $("#test2ID").jQueryPlugin();
});
...
This is done so we could just do test1.foo()… foo is a function inside the jQueryPlugin that is accessible using test1.foo() syntax;
So we have an array of strings which contains (test1, test2, …)
and we need to access foo() while on the loop:
for(i=0; i < theArrayOfStrings.length; i++){
theArrayOfStrings[i].foo();
//so here is the problem... we can't do test1.foo(), test2.foo() ... =(
}
Any idea on how to call function foo() while on the loop?
Or can we convert a string value to a variable in javascript?
eval() function is used to evaluate script in a string variable. For example :
But take a lok at this question before use When is JavaScript’s eval() not evil?