字符串到jQuery.function [英] String to jQuery.function
本文介绍了字符串到jQuery.function的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 jquery <调用字符串方法的最简单方法是什么? / a>?
What's the simplest way to call a string method with jquery?
推荐答案
如果我理解你的问题,你想调用一个名字存储在字符串中的方法。
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]();
这篇关于字符串到jQuery.function的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文