coolbeet
coolbeet

Reputation: 1665

Javascript combine two string always take off the string after space?

I simply just try to combine two string like:

var temp = "<meta property='og:title'  content="; temp += "work1 work2"; temp += "/>";

document.write(temp);

But the result is always:

<meta property='og:title'  content=work1 />

But is should be:

<meta property='og:title'  content=work1 work2 />

I am new to javascript and any help is appreciated, thanks:-)

Upvotes: 0

Views: 87

Answers (1)

Eugene
Eugene

Reputation: 1959

Add single quotes for scope content attribut value:

var temp = "<meta property='og:title'  content='"; temp += "work1 work2"; temp += "' />";

document.write(temp);

Upvotes: 2

Related Questions