function insertAfter(newElement,targetElement){ //在已有元素后面插入一个新元素,属于通用型函数 var parent = targetElement.parentNode; if(parent.lastChild == targetElement){ parent.appendChild(newElement); }else{ parent.insertBefore(newElement,targetElement.nextSibling); } } function prepareGallery() { //遍历数组 if(!document.getElementsByTagName) return false; if(!document.getElementById) return false; if(!document.getElementsByTagName||!document.getElementById) { return false; } var gallery = document.getElementById("p_w_picpathgallery"); var links = gallery.getElementsByTagName("a"); for( var i=0; i < links.length; i++) { links[i].onclick = function(){ return !showPic(this); } links[i].onkeypress = links[i].onclick; } }
转载于:https://blog.51cto.com/xuyran/1783590