0

我只是尝试组合两个字符串,例如:

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 新手,不胜感激,谢谢:-)

4

1 回答 1

2

为范围内容属性值添加单引号:

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

document.write(temp);
于 2013-05-18T09:17:15.380 回答