-
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函数调用</title>
<script type="text/javascript">
function tcon()
{
alert("恭喜你学会函数调用了!");
}
</script>
</head>
<body>
<form>
<input type="button" value="点点我" onclick="tcon()">
</form>
</body>
</html>
查看全部 -
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>流程控制语句</title>
<script type="text/javascript">
//第一步把之前的数据写成一个数组的形式,定义变量为 infos
var infos = [["小A","女",21,"大一"],
["小B","男",23,"大三"],
["小C","男",24,"大四"],
["小D","女",21,"大一"],
["小E","女",22,"大四"],
["小F","男",21,"大一"],
["小G","女",22,"大二"],
["小H","女",20,"大三"],
["小I","女",20,"大一"],
["小J","男",20,"大三"]
];
//第一次筛选,找出都是大一的信息
var dayi=new Array();
for(var i=0;i<infos.length;i++) {
if("大一" == infos[i][3]) {
dayi.add(infos[i]);
//第二次筛选,找出都是女生的信息
if("女" == infos[i][1]) {
document.write(infos[i]);
}
}
}
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>while</title>
<script type="text/javascript">
var mynum =1;//mynum初值化数值为1
while (mynum<=5)
{
document.write("数字:"+mynum+"<br>");
mynum=mynum+1;
}
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>switch</title>
<script type="text/JavaScript">
var myweek =3;//myweek表示星期几变量
switch(myweek)
{
case 1:
case 2:
document.write("学习理念知识");
break;
case 3:
case 4:
document.write("到企业实践");
break;
case 5:
document.write("总结经验");
break;
default:
document.write("周六、日休息和娱乐");
break;
}
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>二维数组</title>
<script type="text/javascript">
document.write("two array.");
var myarr = new Array();
for(var i = 0; i < 3; i++) {
myarr[i] = new Array();
for(var j = 0; i < 6; j++) {
myarr[i][j] = i * j;
document.write("arr["+i+"]["j"]=" + myarr[i][j]+"<br>");
}
}
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数组</title>
<script type="text/javascript">
//创建数组
var arr = ["*", "##", "***", "&&", "****", "##*"];
arr[7]="**";
//显示数组长度
document.write("arr.length :"+arr.length);
//将数组内容输出,完成达到的效果。
for(var i=0; i<arr.length; i++) {
document.write("<br>"+arr[i]);
}
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>变量赋值</title>
<script type="text/javascript">
var num1=10;
var num2="JS";
document.write("num1的值是:"+num1);
document.write("<br>num2的值是:"+num2);
</script>
</head>
<body>
</html>
查看全部 -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>声明变量</title>
<script type="text/javascript">
var mya;
mya=5;
alert("mya的值是:"+(++mya));
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>变量命名</title>
<script type="text/JavaScript">
var myname = 'var no start write : % + /';
document.write(myname);
</script>
</head>
<body>
</body>
</html>
查看全部 -
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全带,准备启航</title>
<!--引入外部文件的方式,src等号间不能有空格-->
<script type="text/javascript" src="script.js">
//多行注释
// 我是多行注释!
// 我需要隐藏,
// 否则会报错哦!
//单行注释
// 我是单行注释,我也要隐藏起来!
</script>
</head>
<body>
</body>
</html>
# 编写script.js文件 :
//编写JS代码
//在页面中显示文字
document.write("系好安全带,准备启航--目标JS");
//页面中弹出提示框
alert("准备好了,起航吧!");
//var dlg = confirm("准备好了,起航吧!");
查看全部 -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>我们互动下</title>
<script = "text/javascript">
document.write("JS进阶篇");
var dlg = confirm("关注JS高级篇");
if(dlg) {
document.write("<br>已关注");
} else {
document.write("<br>未关注");
}
</script>
</head>
<body>
</body>
</html>
查看全部 -
round()
就是四舍五入取值
例:2.5返回3
5.1返回5
查看全部 -
向下取整floor()
与ceil()是相反的
例:3.9返回3
-8.9返回-9
查看全部 -
查看全部
-
使用 substr() 从字符串中提取一些字符
1.和substring差不多,substr可以输入负数,从字符串的尾部开始算起的位置,-1 指字符串中最后一个字符,-2 指倒数第二个字符,以此类推。
substr和substring的区别
主要是参数的区别:1.substring(a,b) 参数a表示起始索引号,即起始的字符的位置,是一个数字; 参数b表示终点索引号,即终点的字符的位置,是一个数字;substring(a,b)返回的字符串的长度length=b-a(规定b>a的情况)
查看全部
举报