JS基础 --输出语法

JS基础 --输出语法

1.alert()

  • 以浏览器弹出层的形式展示内容

  • 小括号里面书写你要输出的内容

  • 只要不是纯数字, 都用引号包裹(单引号双引号无所谓)

     alert 输出内容
        alert('hello world')
        alert(1234567890)
    

2.console.log()

  • 在浏览器控制台打印你要输出的内容

  • 小括号里面书写你要输出的内容

  • 只要不是纯数字, 都用引号包裹

    console.log 输出内容
        console.log('hello world')
        console.log(1234567890)
        console.log('<h1>12312</h1>')
    

3.document.write()

  • 在页面直接写入你要输出的内容

  • 小括号里面书写你要输出的内容

  • 只要不是纯数字, 都用引号包裹

  • 特殊:

    • 直接把内容输出再页面上

    • 所以可以解析标签

      document.write 输出内容
          document.write('hello world')
          document.write('</br>')
          document.write('<h1>')
          document.write(1234567890)
          document.write('</h1>')
      

猜你喜欢

转载自blog.csdn.net/w_cyj/article/details/108416424