!DOCTYPE html
html lang=
head
meta charset=UTF-8
meta name=viewport content=width=device-width, initial-scale=1.0
titleshowPic图片库/title
style type=text/css
#RePicture img{
width:200px;
height:200px;
}
/style
/head
body
h2这是一个图片库/h2
ul
lia href=1.jpg οnclick=showPic(this);op.innerHTML=this.innerHTML;return false我好可爱呢/a/li
lia href=2.jpg οnclick=showPic(this);op.innerHTML=this.innerHTML;return false民国哭的表情包/a/li
lia href=3.gif οnclick=showPic(this);op.innerHTML=this.innerHTML;return false新新超人/a/li
lia href=4.jpgοnclick=showPic(this);op.innerHTML=this.innerHTML;return false月月唱歌/a/li
/ul
div id=RePicture
img src=1.jpg
p id=tip这是一张我好可爱呢的表情包/p
/div
script
function showPic(index){
var RePicture = document.getElementById(RePicture);
var img = RePicture.getElementsByTagName(img)[0];
img.setAttribute(src,index);
}
var op= document.getElementById(tip);
/script
/body
/html
可以参考一下
取消
评论