2

I need to print a var in a jQuery .html() function.. How do i do this?

.html('<table><tr><td><!-- VAR PRINT HERE? --></tr></td>')

1 Answer 1

12

Assuming your variable is in JavaScript:

.html('<table><tr><td>' + variable_name_here + '</tr></td>')

This simply concatenates (adds, glues together) the first string, then your variable, then the second string.

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.