1.图片切换
<html> <head> <title>图片切换</title> <script type="text/javascript"> function changeOther(){ var beauty=document.getElementById("beauty"); beauty.src="p_w_picpaths/xiaoqingchun.jpg"; } function changeOrg(){ var beauty=document.getElementById("beauty"); beauty.src="p_w_picpaths/dk.png"; } </script> </head> <body> <img id="beauty" src="p_w_picpaths/xiaoqingxin.jpg" /> </body> </html>
注意把src里的路径换掉
2.字符串
<script> var str="Hello world!"; document.write(str.indexOf("Hello") + "<br />"); document.write(str.indexOf("World") + "<br />"); document.write(str.indexOf("world")); </script>
可以直接复制在文本文档中,浏览器运行,后缀是html