夜间模式的开启与关闭
<!DOCTYPE html> <html lang="en" xml:color="http://www.w3.org/1999/xhtml"> <head> <meta charset="UTF-8"> <title>Title</title> <script> function mySwitch() { var myele= document.getElementById("on_off") if(myele.src.match("touch_bbs_thread_img_26459100_1455531733.3102")) { myele.src="https://gss0.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D600%2C800/sign=845f9b9993cad1c8d0eef4214f0e4b31/4a36acaf2edda3ccc8c8339607e93901213f925c.gif" document.getElementById("myBody").style.background = "black" document.getElementById("myBody").style.color="white" } else{ myele.scr="http://touch.hupucdn.com/touch_bbs_thread_img_26459100_1455531733.3102.jpeg" document.getElementById("myBody").style.background = "white" document.getElementById("myBody").style.color="black" } } </script> </head> <body id="myBody"> <img id="on_off" onclick="mySwitch()" src="http://touch.hupucdn.com/touch_bbs_thread_img_26459100_1455531733.3102.jpeg" width="500px"> <script> document.write(Date()) </script> </body> </html>
原文:http://www.cnblogs.com/dujiacheng789/p/7780908.html