javascript实现点亮灯泡特效示例

本文实例为大家分享了javascript实现点亮灯泡特效的具体代码,供大家参考,具体内容如下

<!doctype html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport"

content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<meta name='description' content='本文来源于Apollo个人整理,仅供参考!'>

<title>点亮灯泡</title>

<style type="text/css">

div{

width: 500px;

height: 400px;

background-color:lightgoldenrodyellow;

}

</style>

</head>

<body>

<div>

<img id="demo" src="./pic_bulboff.gif" alt="灯泡">

</div>

<script>

document.getElementById('demo').onclick = function () {

ele = document.getElementById('demo');

if (ele.src.match('bulbon')){

ele.src = './pic_bulboff.gif';

}else{

ele.src = './pic_bulbon.gif';

}

}

</script>

</body>

</html>

图片pic_bulboff.gif

图片pic_bulbon.gif

以上是 javascript实现点亮灯泡特效示例 的全部内容, 来源链接: utcz.com/z/332512.html

回到顶部