本文是w3school的学习笔记......
document.write("是啥")在html加载完成之后再加载此函数,会将全部的文档覆盖..
onclick="function()" 就是找到js的那个函数,具体对某一节点进行什么操作
document.getElementById("sha").innerHTMl="sha";
function 的写法和Java格式是一样的,目前来看是一样????这个待定
function Myfunction(){
%方法体%;
}
JavaScript对大小写敏感,语句和变量both,Java也敏感,Python同样.html不敏感,官方推荐全部用小写....
JavaScript会忽略script中所有的空格
//进行注释 /* */多行注释
document.write(var +"<br>")换行这样处理
变量的数字表示:123e5 12300000
123e-5 0.00123
var flag=true or false;
数组 var shuzu=new Array();
shuzu[0]="asd";
or var shuzu=new Array("asd");
属性 var person={firstname:"asd",};这里有个结束的标识符要注意...
寻址方式 person.name 或者person["name"] Python只有 person["name"] Java只有hashmap
声明新变量 var name=new String(); 当然也可以将其定义为var name=null;
JavaScript中所有的都是对象,数组,字符串,日期等,都有属性和方法
条件运算符
greetingname=(condition)? "one":"two";
if else if else switch Python就没有....if(条件){ }else{ }
for(;;) for(x in y){}
break continue do while while...常规
label :语句??
try catch throw 用于自定义的错误?? try{ throw 报错,alert啥的? }catch(){ }
str.indexOf("@") or str.lastindexOf(".")
查找html元素:通过id ,class ,标签tag <div>啥的getElementByTagName getElementByClass 可以改变其src 和style什么的...
onchange onmouseover onmouseout
onmousedown onmouseup onclick 和鼠标点击相关的
document.createElement("");
document.createTextNode("").appendChild("")
removeChild("") remove必须获得其父类然后将其子节点删除
对字符串的处理:
str.length str.big str.small str.indexOf() str.fontcolor("Red") str.fontSize() str.blod str.italics str.toLowerCase() str.toUpperCase()
str.link str.sub str.sup