开发者

JQuery and Dynamic javascript execute

开发者 https://www.devze.com 2023-02-26 09:52 出处:网络
Suppose one line or few lines of javascript is assigned to a variable. How could I execute it by jQuery.开发者_StackOverflow中文版

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

精彩评论

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