Correct way to to call apply on JQuery array
i want to call a jQuery function, the name of the function is from a
string, the parameters of the function are from an array, for example:
# value of fName and aParams are from user input
fName = 'text';
aParams = [ 'a content' ];
var elem = $('#test'); # a div
elem[fName].apply(elem,aParams); # no effect, i don't know why it's failed
the desired result are:
elem[fName](aParams[0], aParams[1], ...)
No comments:
Post a Comment