<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>电灯开关</title>
</head>
<body>
<img id="1" src="img/off.gif" alt="">
<script>
var e1 = document.getElementById("1");
var flag=false;
e1.ondblclick=fun;
function fun() {
if(flag){
e1.src="img/off.gif"
flag=false;
}else {
e1.src="img/on.gif"
flag=true;
}
}
</script>
</body>
</html> |
|