开发者

JQuery and Dynamic javascript execute

Suppose one line or few lines of javascript is assigned to a variable. How could I execute it by jQuery.

开发者_StackOverflow中文版

Suppose alert($("#txtName").val());

The above code is assigned to a variable then how could I execute it by jQuery at run time.


You could use the eval function. Example:

var someCommand = 'alert($("#txtName").val());';
eval(someCommand);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜