Skip to content Skip to sidebar Skip to footer

String To Jquery.function

What's the simplest way to call a string method with jquery?

Solution 1:

If I understand your question correctly, you want to call a method whose name is stored in a string.

If that's the case, you should use square bracket notation instead of (not in addition to) dot notation, and delimit the literal string with quotes:

$["STRINGVALUE"]();

You can also use the variable you defined initially, without quotes:

$[myFunction]();

Post a Comment for "String To Jquery.function"