Below is the code snippet
var docd = {message: 'hi'};
chatHTML += `<div class="message"> ${docd.message} </div>
<i class="fas fa-reply" onclick=expand('${docd.message}')></i>
</div>`;
$(".message-container").html(chatHTML);
function expand(message,)
{
console.log(message);
}
So the above code works just Fine.
Now if i change the variable value as
var docd = {message: 'hi hello how are you'}; // Added spaces inbetween
Now when the onclick event is called I am getting a error as
Unexpected or Invalid token
Is it because the second string what i am passing is having spaces? Or is there any other issues? How to solve this? Any help appreciated.
onclick=expand('${docd.message})must beonclick=expand('${docd.message}')instead.