1

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

4

You could use the eval function. Example:

var someCommand = 'alert($("#txtName").val());';
eval(someCommand);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.