I need to call a function in the following fashion:
var f = 'fadeOut';
$(v).f(s, function(){
$(v).css('visibility', 'hidden').css('position', 'absolute');
});
Is this possible to do simply?
var function_name = "string"; function_name = window[function_name];
The JavaScript call() Method The call() method is a predefined JavaScript method. It can be used to invoke (call) a method with an owner object as an argument (parameter). With call() , an object can use a method belonging to another object.
Define a function named "myFunction", and make it display "Hello World!" in the <p> element. Hint: Use the function keyword to define the function (followed by a name, followed by parentheses). Place the code you want executed by the function, inside curly brackets. Then, call the function.
To convert a string in to function "eval()" method should be used. This method takes a string as a parameter and converts it into a function.
Yes
var f = 'fadeOut';
$(v)[f](s, function(){
$(v).css('visibility', 'hidden').css('position', 'absolute');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With