+ 1

How can I put a variable value inside a string.

var red = 24; var green = 87; var blue = 50; document.getElementById ("para").style.background = "rgb(red green blue)"; How I put those variable values inside string to apply the background colour.

30th Jul 2019, 4:21 PM
Noor
Noor - avatar
3 Respostas
+ 1
with the + sign. it can concat two strings or other types by converting them automatically to string. ... = "rgba(" + red + ", " + green + ", " + blue + ", 1.0)";
30th Jul 2019, 4:41 PM
Anton Böhler
Anton Böhler - avatar
+ 1
Thank you for your help.
31st Jul 2019, 3:28 AM
Noor
Noor - avatar
0
n : m l
3rd Aug 2019, 9:15 AM
青木岐夫
青木岐夫 - avatar