JS学习脚本

 DOM:node

关键字:getElementById() getElementsByTagName()获取为数组形式;数组

设定属性:getAttribute()  setAttribute()app

获取子元素:childNode(数组形势) firstChild  lastChildide

nodeType 1表示元素  2表示属性 3表示文本nodeValue函数

建立元素:createElements()  插入元素:parent.appendChild() spa

设定插入文本:createNodeText()事件

插入insertBefore()get

function insertAfter(newElement,targetElement){it

var parent= targetElement.parentNode;io

if(parent.lastChild ==targetElement){

parent.appendChild(newElement);

}

else{parent.insertBefore(newElement,targetElement.nextSibling);}

 

}

事件加载多个函数:

function addLoadEvent(func){

var oldonload = window.onload;

if(typeof window.onload !='function')

{

window.onload =func;

}

else

{window.onload=function(){oldonload();func();}}

}

相关文章
相关标签/搜索