2013-05-18 60 views
0

我只是簡單地嘗試兩個字符串像結合:Javascript結合兩個字符串總是在空格後脫掉字符串?

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

document.write(temp); 

但結果總是:

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

但就是應該是:

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

我是新來的JavaScript和任何幫助表示讚賞,謝謝:-)

+0

對不起,以後我看到了強調「WORK2」我知道我做錯了,它應該是什麼溫度+ =「‘哈哈laiba’」; – coolbeet

回答

2

添加單引號fo [R範圍內容attribut值:

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

document.write(temp);