1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
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( "imagegallery" );
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;
}
}
|
本文转自 小旭依然 51CTO博客,原文链接:http://blog.51cto.com/xuyran/1783590