关于document.write的语法 课程中也没讲,都哪些写法可以普及下吗
来源:5-8 编程练习
我叫壹陆伍
2021-02-04 21:39:24
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>index</title>
</head>
<body>
<script>
var x=4,y=5,result2=x-y,result3=x/y,result4=x*y,result5=x%y;
console.log(result2);
console.log(result3);
console.log(result4);
console.log(result5);
document.write("result2值为-1");
</script>
</body>
</html>
1回答
好帮手慕言
2021-02-05
同学你好,同学提供的代码中,没有加法运算,建议添加上,如下:
另外:document.write()方法可向文档中写入内容,把要写入的内容放到括号中,例如:
效果:
祝学习愉快~
相似问题