javascript复习总结

时间:2023-03-09 02:15:34
javascript复习总结

改变HTML内容:document.getElementById(id).innerHTML = new HTML;

改变HTML属性:document.getElementById(id).innerHTML.attribute[属性] = new value;

改变HTML样式:document.getElementById(id).style.property[样式] = new style;

事件:

onload:用户进入页面完成加载触发; 例如:onload="函数"[navigator.cookieEnabled==true](可用于cookie)

onunload:用户离开页面时触发;

onchange:当离开输入字段时触发;

onmouseover:当鼠标移到元素上触发;

onmouseout:当鼠标离开元素触发;

onclick:当鼠标点击元素时触发;

onmousedown:当鼠标点击元素不释放时触发;

onmouseup:当鼠标释放元素时触发;

onfocus:获得焦点时触发;

appendChild:添加新元素;

removeChild:删除元素;

parentNode:父元素;

对象构造器:

  function person(firstname,lastname,age){

    this.firstname=firstname;

    this.lastname = lastname;

    this.age=age;

  }

  var object =new person("Bill","Gates","25");