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



  • 相关阅读:
    VLC 播放完毕后自动退出的问题
    配置Linux文件句柄数
    java获取某一天的邮件
    oracle wm_concat函数将多行转字段函数
    Vue学习(二十五)TS支持
    Vue学习(二十四)render函数
    Vue学习(二十三)路由全攻略
    git commit规范&工具安装使用
    Vue学习(二十二)自定义指令全攻略
    Vue学习(二十一)$emit全攻略
  • 原文地址:https://www.cnblogs.com/yangchuanqi/p/8100014.html
Copyright © 2011-2022 走看看