js的输出

  • 使用 window.alert() 写入警告框
  • 使用 document.write() 写入 HTML 输出
  • 使用 innerHTML 写入 HTML 元素
  • 使用 console.log() 写入浏览器控制台

innerHTML要配合 document.getElementById(id) 方法使用

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = 5 + 6;
</script>

按钮触发见: https://www.cnblogs.com/kaibindirver/p/9781670.html

其他参考 https://www.w3school.com.cn/js/js_output.asp

猜你喜欢

转载自www.cnblogs.com/kaibindirver/p/13190925.html