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写脚本

    根据自己的需要选择

  • 相关阅读:
    常用Js笔记,以后可能用得上
    基于Nop增删改查代码模板
    使用Layer Confirm弹窗没有点击确定按钮就执行了确定方法
    页面表单传值
    2018年5月2日 问题记录
    循环分页请求
    git删除commit方法和误删commit后的恢复方法
    git切换分支
    系统化的思考模式
    实践!实现纯前端下的音频剪辑处理
  • 原文地址:https://www.cnblogs.com/peterli2013/p/3179309.html
Copyright © 2011-2022 走看看