本文介绍了未终止的字符串常量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了一个JavaScript错误,无法修复未终止的字符串常量.
这就是我想要做的
Hi,
I have this javascript error that I am unable to fix unterminated string constant.
Here is what I am trying to do
var test = '<p>rajnas asdjhsadnmdas dasjads jmsad dasndsaads bnas</p>
<p>ahdndsa</p>';
document.getElementById('education').innerHTML = test;
推荐答案
var test = "<p>rajnas asdjhsadnmdas dasjads jmsad dasndsaads bnas" + "\n" +
"<p>ahdndsa</p>"
document.getElementById('education').innerHTML = test;
var test = '<p>rajnas asdjhsadnmdas dasjads bnas</p><p>ahdndsa</p>';
在一行中,但是如果我在行下写
in a single line, but if i write below line
<p>ahdndsa</p>';
在新行中,则仅给出连续的字符串常量错误.
因此,请尝试将(var test)值放在一行中,如下面的代码所示.希望它能做到.
in new line then only its giving unterminated string constant error .
so try to put (var test) value in a single line as in below code . Hope it will do.
<script>
function aa()
{
var test = '<p>rajnas asdjhsadnmdas dasjads bnas</p><p>ahdndsa</p>';
document.getElementById('education').innerHTML = test;
}
</script>
<body>
<a href="#" onclick="aa()">click</a>
<div id="education">
</div>
</body>
添加了代码块[/编辑]
Code block added[/Edit]
这篇关于未终止的字符串常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!