Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print a javascript variable in a jQuery .html() function?

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>')
like image 742
user663049 Avatar asked Nov 28 '25 09:11

user663049


1 Answers

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.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!