引用生成器网站不能在显示的内容之间放置符号或空格

reference generator website cannot put symbols or spaces between displayed content

本文关键字:之间 符号 空格 网站 不能 显示 引用      更新时间:2023-09-26

我正在设计一个参考生成器网站,我正在直接在页面上打印文本框值,但我无法在两个文本框显示值之间集成空间或符号请告诉我如何在显示的内容之间添加符号或空格

这是我的代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<html>
<head>
</head>
<body>
<script type="text/javascript">
function changeThis(){
	var formInput = document.getElementById('theInput').value;
	document.getElementById('newText').innerHTML = formInput;
        var formInput = document.getElementById('theInput2').value;
	document.getElementById('newText2').innerHTML = formInput;
}
</script>
 
<input type='text' id='theInput' value='' />
<input type='text' id='theInput2' value='' />
<input type='button' onclick='changeThis()' value='generate'/>
<br>RESULT <span id='newText'></span><span id='newText2'></span> </p> 
</body>
</html>
</body>
</html>

只需使用十六进制实体&#x20;

Fiddle-http://jsfiddle.net/1278p7c5/

您可以在2个重用之间添加带有样式空白的span:pre,或者您可以在第二个span左侧添加填充,请使用空白pre-尝试此示例

function changeThis(){
    	var formInput = document.getElementById('theInput').value;
    	document.getElementById('newText').innerHTML = formInput;
            var formInput = document.getElementById('theInput2').value;
    	document.getElementById('newText2').innerHTML = formInput;
    }
 function changeThis(){
    	var formInput = document.getElementById('theInput').value;
    	document.getElementById('newText').innerHTML = formInput;
            var formInput = document.getElementById('theInput2').value;
    	document.getElementById('newText2').innerHTML = formInput;
    }
 <input type='text' id='theInput' value='' />
    <input type='text' id='theInput2' value='' />
    <input type='button' onclick='changeThis()' value='generate'/>
    <br>RESULT <span id='newText'></span><span style="white-space:pre">     </span><span id='newText2'></span> </p>