封装函数减少代码量
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="button" value="显示大图" id="btn" />
<img src="images/1.jpg" alt="" id="btn2">
<script>
function my$(id){
return document.getElementById(id);
}
// document.getElementById("btn").onclick=function() {
// document.getElementById("btn2").src = "images/2.jpg";
// };
my$("btn").onclick=function() {
my$("btn2").src = "images/2.jpg";
};
</script>
</body>
</html>
卡卡,你好吗