zoukankan      html  css  js  c++  java
  • JavaScript基础

    基础语法:与C#一致

    --------------------------------------------------------------

    弹出框: alert();confirm();

    --------------------------------------------------------------

    数据类型 var (string,decimal)

    --------------------------------------------------------------

    类型转换  parseInt() ;   parseFloat();  isNaN();

    --------------------------------------------------------------

    运算符:
    数学运算符:+ - * /  ++ --   %
    关系运算符:== != >= <= > <
    逻辑运算符:&&   ||   !
    其他运算符:+= -= *= /=  ?:

    --------------------------------------------------------------

    语句:分支语句,循环语句

    --------------------------------------------------------------

    数组:Array();

    --------------------------------------------------------------
    函数:function
    funciton 函数名(a)
    {
        return ??;
    }

    --------------------------------------------------------------

    Dom操作
    var a =document.getElementById();
    var b =document.getElementsByClassName();
    document.getElementsByName();
    document.getElementsByTagName();

    window.open('','_blank');
    window.close();
    window.opener  -  返回的是一个窗口对象
    window.setInterval(function(){},2000);
    window.setTimeout(funciton(){},2000);
    window.clearInterval();
    window.scrollTo(x,y);

    window.history.go(-1);

    window.location.href="url"; - 当前页面跳转
    var a = window.location.href; - 获取当前页面地址

    --------------------------------------------------------------

    操作元素的样式
    a.style.backgroundColor = "red";
    a.style.width="10px";
    a.offsetTop/Left/Width/Height - 实时数据

    --------------------------------------------------------------

    操作元素的内容
    表单元素 - value
    非表单元素 - innerHTML   innerText
    --------------------------------------------------------------
    操作元素的属性
    setAttribute('','');
    getAttribute('');
    removeAttribute('');
    --------------------------------------------------------------
    创建及删除元素
    对象.innerHTML= "标记拼好的字符串";
    var a = document.createElement('div');
    a.setAttribute('class', 'div2');
    document.getElementById('div1').appendChild(a);
    --------------------------------------------------------------
    对象.parentNode.removeChild(对象);
    获取相关元素
    获取对象父级
    对象.parentNode
    获取对象子级
    对象.childNodes
    获取哥哥
    对象.previousSibling - 注意!!!空格及回车占一位
    或取弟弟
    对象.nextsibling - !!! 空格及回车占一位

    --------------------------------------------------------------

    常用事件
    onclick
    onmouseover/onmouseout
    onfocus/onblur
    onkeyup
    ondblclick



  • 相关阅读:
    深入浅出ES6(十二):代理 Proxies
    深入浅出ES6(十一):生成器 Generators,续篇
    深入浅出ES6(十):集合
    深入浅出ES6(九):学习Babel和Broccoli,马上就用ES6
    深入浅出ES6(八):Symbols
    根据后端返回的数据进行中文排序操作
    vue之组件(组件之间相互传参)
    mongodb用户权限增删改查
    mongodb添加文件和导出文件
    js中cookie编码解码操作
  • 原文地址:https://www.cnblogs.com/yangchuanqi/p/8100014.html
Copyright © 2011-2022 走看看