标签:
<html> <head> <script type="text/javascript"> var fruits= ["苹果","鸭梨","橙子"];//建议这样定义、初始化数组 with(document){ writeln("<ul>"); writeln("<li>"+fruits.join()+"</li>"); writeln("<li>"+fruits.join("--")+"</li>"); writeln("<li>"+fruits.reverse().join()+"</li>"); writeln("<li>"+fruits.valueOf()+"</li>"); writeln("</ul>"); } </script> </head> </html>
<html> <head> <script type="text/javascript"> var str="javascript"; var num=1234; with(document){ writeln(str.toUpperCase()+"<br>"); writeln(num.toString().charAt(3)+"<br>"); writeln(str.substring(0,4)+"<br>"); } </script> </head> </html>
运行结果:
JAVASCRIPT
3
java
<html> <head> <script type="text/javascript"> function isEmail(){ var emailValue=document.getElementsByName("email")[0].value; if(emailValue.indexOf("@")==-1){ alert("请输入正确的电子邮件"); }else{ alert("ok"); } } </script> </head> <body> <input type="text" name="email" > <input type="button" value="check" onclick="isEmail();"> </body> </html>
标签:
原文地址:http://www.cnblogs.com/qq-757617012/p/4177171.html