js的第二個特效燈泡開關

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">html

<html xmlns="http://www.w3.org/1999/xhtml">ui

<head>spa

<title>新建網頁</title>xml

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />htm

<meta name="description" content="布爾教育 http://www.itbool.com" />ip

<script>utf-8

function toggle() {get

//開關燈泡切換it

var test1=document.getElementById('on');io

if(test1.src.indexOf('on')>=0){

test1.src="off.png";

}

else{

test1.src="on.png";

}

}

</script>

</head>

    <body>

     <img id='on' src="on.png" alt="" onclick="toggle();"/>

    </body>

</html>

相關文章
相關標籤/搜索