1. Get the next element of the current element
function getNextElement( node){
if(node.nodeType==1){
return node;
}
if(node.nextSibling){
return getNextElement(node.nextSibling);
}
return null;
};
2. Externally introduced js, add page loading method
function addLoadEvent(func){
var oldonload=window.onload;
if(typeof window.onload!='function' ){
window.onload=func;
}else{
window.onload=function(){
oldonload();
func();
}
}
};
3.insertAfter method
function insertAfter(newElement,targetElement){
var parent=targetElement.parentNode;
if(parent.lastChild==targetElement){
parent.appendChild(newElement);
}else{
parent.insertBefore(newElement,targetElement.nextSibling);
}
};
4. Add class
function addClass(element,value){
if(!element.className){
element .className=value;
}else{
newClassName=element.className;
element.className=newClassName " " value;
}
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn