zoukankan      html  css  js  c++  java
  • javascript基础教程学习总结(1)

    摘自javascript基础教程

    开始:

    1.将脚本放在哪里:

    1.1 放在html和<html>之间

    范例:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>javascript</title>
    <script type="text/javascript">
    window.onload = writeMassage;
    function writeMassage() {
    document.getElementById("helloMessage").innerHTML = "hello world";
    }
    </script>
    </head>

    <body>
    <h1 id="helloMessage">
    </h1>
    </body>
    </html>

    1.2 放在标签之间

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>javascript</title>
    </head>
    <body>
    <h1 id="helloMessage">
    <script>
    document.getElementById("helloMessage").innerHTML = "hello world";
    </script>
    </h1>
    </body>
    </html>

    1.3 使用外部脚本

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>javascript</title>
    <script src="script01.js"></script>
    </head>
    <body>
    <h1 id="helloMessage">
    </h1>
    </body>
    </html>

    script.01.js写脚本

    根据自己的需要选择

  • 相关阅读:
    枚举类型总结
    正则表达式-Java
    java中Mongo
    cookie
    xsd解析
    水平分表的实现
    c#位运算小例子笔记
    c#设计模式之观察者模式(Observer Pattern)
    c#设计模式之代理模式(Proxy Pattern)
    .Net 数据缓存浅析
  • 原文地址:https://www.cnblogs.com/peterli2013/p/3179309.html
Copyright © 2011-2022 走看看