zoukankan      html  css  js  c++  java
  • 如何编写及运行JS

    JS也是一种脚本语言,他可以有两种方式在HTML页面进行引入,一种是外联,一种是内部。
     
        外联JS的写法为:
      
     <script src="相对路径"></script>
            这是一条html语句,原则上可以放在html页面的任意位置,不用和link标签一样非得放在head部分
            相对路径链接的是JavaScript文件,文件的扩展名为.js,如index.js
        
        内部JS的写法为:   
         <script>
                //在script标签内写js脚本
            </script>
       
    错误的写法:        
            <script src="相对路径">
                //在script标签内写js脚本
            </script>    
     
        向页面中打印内容:   
     document.write(“这是一些文本内容”);
     
      可以直接解析标签:    
     document.write(“<strong>加粗的内容</strong>”);
     
        转义字符:     
            &lt;  ====  <
            &gt;  ====  >
            document.write(“&lt;strong&gt;这是一些加粗的内容</strong>”);    

     

    console.log("hello world")
    向浏览器的控制台打印信息,跟document.write()原理类似
  • 相关阅读:
    变量
    总结 对象
    学生管理系统
    [Altera] Device Part Number Format
    [Matlab] sum
    [Matlab] Galois Field
    [C] static和extern的作用
    [Python] list
    [Python] raw_input
    [软件] UnicornViewer
  • 原文地址:https://www.cnblogs.com/qdjl/p/9241865.html
Copyright © 2011-2022 走看看