classification

javascript insertAfter method

2012年3月22日 00:04 | Comments(1) | Category:javascript | Tags:

 

//insertAfter method
function insertAfter(newElement,targetElement) {
	var parent = targetElement.parentNode; 
	if (parent.lastChild == targetElement)  parent.appendChild(newElement); 
		else parent.insertBefore(newElement,targetElement.nextSibling); 
}