如何在javascript结果中添加断点



我想知道是否有人能告诉我如何在我的。innerhtml中添加类似的东西。

现在,它列出的答案如下:

两数相加4两数相减0两数相乘4两数相除1

都是一行,我想知道是否有一种方法可以把它分开,让它看起来像列表项。

:

  • 两个数字相加4
  • 减去两个数字0
  • 两个数字相乘4
  • 两个数字相除1

只是没有要点。

下面是我的代码:

提前感谢!

<!DOCTYPE html>
<html>
<head>
	<title></title>
	<script type="text/javascript">
		var e,f;
		function values()
		{
			e = Number(document.getElementById("e").value);
			f = Number(document.getElementById("f").value);
		}
		function MULTI()
		{
			values();
			result = (e+f);
			result1 = (e-f);
			result2 = (e*f);
			result3 = (e/f);
			document.getElementById("MULTI").innerHTML = "Adding the two numbers" +result
			+ "Subtracting the two numbers " +result1 
			+ "Multiplying the two numbers " +result2 
			+ "Dividing the two numbers" +result3;
		}
	</script>
</head>
<body>
		<div id="cylinder">
			<input type="text" id="e" placeholder="Base..."/><br>
			<input type="text" id="f" placeholder="Height..."/><br>
			<input type="button" onclick="MULTI()" value="Calculate!"/>
		</div>
		<div id="MULTI"></div><br><br><br>
</body>
</html>

因为它是html

document.getElementById("MULTI").innerHTML = "Adding the two numbers" +result
            + "<br>Subtracting the two numbers " +result1 
            + "<br>Multiplying the two numbers " +result2 
            + "<br>Dividing the two numbers" +result3;

.innerHTML在元素中写入HTML,因此使用<br />就像在HTML中编写一样:

document.getElementById("MULTI").innerHTML = "Adding the two numbers" +result
        + "<br /> Subtracting the two numbers" +result1 
        + "<br /> Multiplying the two numbers" +result2 
        + "<br /> Dividing the two numbers" +result3;

最新更新