Reputation: 34188
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.
Upvotes: 1
Views: 626
Reputation: 1038730
You could use the eval
function. Example:
var someCommand = 'alert($("#txtName").val());';
eval(someCommand);
Upvotes: 4