<form>
<input type="text" id="clock" size="50" />
<input type="button" value="Stop" onclick="clearInterval(j)" />
</form>
<input type="text" id="clock" size="50" />
<input type="button" value="Stop" onclick="clearInterval(j)" />
</form>
2015-01-20
function clock(){
var time=new Date();
document.getElementById("clock").value = time;
}
var j=setInterval(clock,100) ;
var time=new Date();
document.getElementById("clock").value = time;
}
var j=setInterval(clock,100) ;
2015-01-20
var attime;
function clock(){
var time=new Date();
attime=time.getHours()+':'+time.getMinutes()+':'+time.getSeconds();
document.getElementById("clock").value = attime;
}
setInterval(clock,100);
function clock(){
var time=new Date();
attime=time.getHours()+':'+time.getMinutes()+':'+time.getSeconds();
document.getElementById("clock").value = attime;
}
setInterval(clock,100);
2015-01-20
<script type="text/javascript">
//alert("欢迎来慕课网~");
function myclick(){
window.open("http://www.imooc.com",'_blank',"width=600px,height=400px");
}
</script>
//alert("欢迎来慕课网~");
function myclick(){
window.open("http://www.imooc.com",'_blank',"width=600px,height=400px");
}
</script>
2015-01-20
round() 方法可把一个数字四舍五入为最接近的整数。
语法:
Math.round(x)
参数说明:
注意:
1. 返回与 x 最接近的整数。
2. 对于 0.5,该方法将进行上舍入。(5.5 将舍入为 6)
3. 如果 x 与两侧整数同等接近,则结果接近 +∞方向的数字值 。(如 -5.5 将舍入为 -5; -5.52 将舍入为 -6),如下图:
语法:
Math.round(x)
参数说明:
注意:
1. 返回与 x 最接近的整数。
2. 对于 0.5,该方法将进行上舍入。(5.5 将舍入为 6)
3. 如果 x 与两侧整数同等接近,则结果接近 +∞方向的数字值 。(如 -5.5 将舍入为 -5; -5.52 将舍入为 -6),如下图:
2015-01-20
<script type="text/javascript">
var name;
for(name=1; name<=10;name++){
if(name==5){
continue
}
document.write("数值"+num+"<br/>");
}
</script>
var name;
for(name=1; name<=10;name++){
if(name==5){
continue
}
document.write("数值"+num+"<br/>");
}
</script>
2015-01-19
substring(x,y) 获得字符串中x下标和y下标之间的字符串
substr(x,y) 获得字符串中x下标开始,长度为y字符串
这个是关键
substr(x,y) 获得字符串中x下标开始,长度为y字符串
这个是关键
2015-01-19
<script type="text/javascript">
var mydate=new Date();
var myyear=(mydate.getFullYear());
document.write("年份:"+myyear);
</script>
var mydate=new Date();
var myyear=(mydate.getFullYear());
document.write("年份:"+myyear);
</script>
2015-01-19
最赞回答 / 不加香菜不要葱
因为一旦有一个元素小于60,执行continue就跳出了此次循环,但i的值并没有加1(因为i=i+1在循环体里面并且在continue的后面),所以下次仍然是这个小于60的元素进行判断,陷入了死循环。
2015-01-19
var text=Lists[i].getAttribute("title");
document.write(text +"<br>");
if(text=="")
{
Lists[i].setAttribute("title","WEB前端技术");
document.write(text +"<br>");
if(text=="")
{
Lists[i].setAttribute("title","WEB前端技术");
2015-01-19
//创建数组
var arr=['*','##',"***","&&","****","##"];
arr[7]="**";
//显示数组长度
//alert(arr.length);
//将数组内容输出,完成达到的效果。
for(var i=0;i<=7;i++)
{
document.write(arr[i]+"<br>")
}
var arr=['*','##',"***","&&","****","##"];
arr[7]="**";
//显示数组长度
//alert(arr.length);
//将数组内容输出,完成达到的效果。
for(var i=0;i<=7;i++)
{
document.write(arr[i]+"<br>")
}