请看下面的代码:
但是我得到了以下内容:
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
function ttsSpeak(text)
{
var textArray = text.split(" ");
var finalString="";
for(var i=0;i<textArray.length;i++)
{
finalString = finalString+textArray[i]+"+";
}
alert(finalString);
}
</script>
</head>
<body>
<div><p id="text">In meteorology surface.
</p></div>
<div><button id="speak" onclick="ttsSpeak(document.getElementById('text').innerHTML);">Speak</button></div>
</body>
</html>
在这里,我期望的输出是:
In+meteorology+surface+
但是我得到了以下内容: