[Solved] Quotes for values of html attributes [closed]

The escaped quotes match each other in the HTML string that you’re creating.

The quotes are not “surrounding” +i+. They’re being used to end the string that begins with

"<p id=\"element"

and to begin the next string:

"\">Hello world, ..."

This is concatenating i between these two strings. So if i contains 0, the resulting HTML will be

<p id="element0">Hello world, I'm element 0</p>

The escaped quotes allow the quotes to be put in the string, but you still have to get out of the string to expand a variable.

Javascript is not like PHP, it doesn’t expand variables inside strings (because there’s no special prefix like $ that tells where a variable begins).

solved Quotes for values of html attributes [closed]