• JS基础知识


    目录

    一、JS基本语法

    1.1、基础语法

    1.2 js书写方式

    1.2.1 行内js

    1.2.2 内嵌js【页面中】

    1.2.3 外部js

    1.3 对话框

    1.4 基本语法

    1.4.1 关键字

    1.4.2 注释

    1.4.3 变量

    1.4.4 数据类型

    1.4.5 运算符

    1.5 选择结构

    1.6 循环结构

    二、函数

    2.1 函数的基本概念

    2.2 函数调用

    2.3 函数中变量的定义

    2.4 值传递和引用传递

    2.5 函数做为参数传递

    2.6 默认值函数

    2.7 匿名函数

    2.8 lambda表达式

    2.9 递归

    2.10 函数属性

    2.11 闭包

    三、数组

    3.1 数组的声明

    3.2 数组遍历

    3.3 数组中的常用方法

    3.4 二维数组

    四、常见内置对象

    4.1 Math

    4.2 Date

    4.3 字符串

    五、Bom编程

    5.1 window的属性以及方法

    5.2 history对象

    一、JS基本语法

    1.1、基础语法

    1. <html>
    2. <head>
    3. <meta charset="utf-8" />
    4. <title>title>
    5. head>
    6. <body>
    7.    <div id="div">div>
    8. body>
    9.    
    10. html>
    11. <script>
    12.   alert("hello,js")//提示信息
    13. var divEle =  document.getElementById("div");
    14. divEle.innerHTML='hello,js'
    15. script>

    通过script来进行定义js。script标签可以放着head标记中,也可以放在body中,也可以放在最后。

    1.2 js书写方式

    1.2.1 行内js

    <input type="button" value="点击" onclick="alert('点我干嘛??');"/>

    按钮借助事件【onclick】来触发js代码

    1.2.2 内嵌js【页面中】

    1. <html>
    2. <head>
    3. <meta charset="utf-8" />
    4. <title>title>
    5. head>
    6. <body>
    7.    <div id="div">div>
    8. body>
    9. <script>
    10.   alert("hello,js")//提示信息
    11. var divEle =  document.getElementById("div");
    12. divEle.innerHTML='hello,js'
    13. script>    
    14. html>

    1.2.3 外部js

    创建js文件

    alert("我是外部的js")

    html页面通过