Is it possible to call a function by using the strings ?
(i.e) I have a variable var target = 'next';
. Using this string I want to call the jquery method next()
. Should i use target + '()'
(this is bit foolish) to call next()
?
I know it can be done using conditional
statements. Since it is a string got from users, but it is difficult to use conditional statements for all that.
In my jQuery plugin, users will pass the value prev
, siblings
etc as options, so that the respective jQuery methods will be executed.
How do I implement this ?