zoukankan      html  css  js  c++  java
  • JavaScript学习笔记—变量、元素

    ## js的使用

    1.行内     onclick  点击事件   alert弹出警示框  【不推荐】
    2.内嵌式   script标签  放置两个位置: 1. head标签中  2.body标签结束前
    3.外链式   将js作为外链引入,script标签,利用src属性将地址写入,一旦该标签内含有src属性,该标签内将不能再写入脚本,失效的

    ## 注释

    1.单行注释  //
    2.多行注释  /*注释内容*/

    ## 事件三部曲

    三部曲: 1.找到他 document.getElementById("title") 
            2.做什么(添加事件)  
            3.怎么做,事件函数 function(){}
            
            .的

            window.onload = function(){}  作用:结构先加载语句

            常用事件:
                onclick点击  
                onmouseover鼠标划过 
                onmouseenter鼠标划入 
                onmouseout鼠标划出 
                onmouseleave鼠标划出
                onmousedown鼠标按下 
                onmouseup鼠标抬起 
                ondblclick鼠标双击事件 
                oncontextmenu鼠标右键事件

    ## 调试命令

    1.  alert 弹出框(带有确认按钮)
    2.  console.log 控制台打印  [推荐]

    ## 变量 视为容器


    var声明 a
    变量命名规则:
    1.避免关键字保留字
    2.只能 字母或下划线或$ 开头
    3.避免重名,若重名,则覆盖
    4.见名知意,支持驼峰写法


    ## 以下就是ECMAScript的全部关键字(带*号上标的是第5 版新增的关键字):

    break do  instanceof  typeof  
    case  else  new var 
    catch finally return  void  
    continue  for switch  while 
    debugger* function  this  with  
    default if  throw delete  
    in  try     

    表1-1 关键字

    ECMA-262 还描述了另外一组不能用作标识符的保留字。尽管保留字在这门语言中还没有任何特定的用途。但它们有可能在将来被用作关键字。以下是ECMA-262 第3 版定义的全部保留字:

    表1-2 保留字

    abstract  enum  int short
    boolean export  interface static
    byte  extends long  super
    char  final native  synchronized
    class float package throws
    const goto  private transient
    debugger  implements  protected volatile
    double  import  public   

    第5 版把在非严格模式下运行时的保留字缩减为下列这些:

    表1-3 非严格模式
    class enum  extends super
    const export  import   

    在严格模式下,第5 版还对以下保留字施加了限制:
    表1-4 严格模式
    implements  package public  interface
    private static  let protected
    yield      

    ## 元素内容  既能获取 也能设置

    inner系列  闭合普通标签

    1.innerText 只能识别文本,不能识别标签

    2.innerHTML 既能够识别内容也能够识别标签

    value值  表单使用[包括textarea]

    ## 元素的固有属性 既能获取也能设置

    元素.id
    元素.className
    元素.title

    ## 元素的样式


    元素.style.样式名 = '样式值';

    元素.style.cssText = '样式集合';
  • 相关阅读:
    sqlserver 2005 数据库的差异备份与还原
    sqlserver安装教程
    hibernate左连接查询时在easyUI的dataGrid中有些行取值为空的解决办法
    解释器模式
    命令模式
    责任链模式
    3Sum Closest
    3sum
    代理模式
    外观模式
  • 原文地址:https://www.cnblogs.com/shihaiying/p/13229683.html
Copyright © 2011-2022 走看看