Suppose one line or few lines of javascript is assigned to a variable. How could I execute it by jQuery.
Suppose alert($("#txtName").val());
The above code is assigned to a variable then how could I execute it by jQuery at run time.
1 Answer 1
You could use the eval function. Example:
var someCommand = 'alert($("#txtName").val());';
eval(someCommand);
answered Apr 19, 2011 at 6:11
Darin Dimitrov
1.0m277 gold badges3.3k silver badges3k bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js