Javascript !!!

基础语法:与C#一致
数据类型及类型转换
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[]         --索引从0开始,空格换行都算1
获取哥哥
对象.previousSibling - 注意!!!
或取弟弟
对象.nextsibling - !!!

字符串操作 数学操作

时间日期

onclick
onmouseover/onmouseout
onfocus/onblur
onkeyup/down        --up比down好用

原文地址:https://www.cnblogs.com/m110/p/8097730.html