<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>
新闻热点
疑难解答