js入门例子小结2

感谢张龙的视频


js12.html


<script type="text/javascript">
//鼠标移来移去触发不同的事件
//this 代表当前对象的引用即font对象
function mOver(object){
object.color = "red";
}

function mOut(object){
object.color = "yellow";
}

</script>
  </head>
  
  <body>

<font style="cursor:hand"  οnclick="window.location.href='http://www.baidu.com'" 
  οnmοuseοver="mOver(this)" onmouseOut="mOut(this)"  >  欢迎登陆       </font>

  </body>

js14.html


<script type="text/javascript">
//设置定时时间
function ooo(){
setTimeout("alert('hello')", 1000);//用于指定在一段特定时间后执行某段程序
}
</script>
  </head>
  
  <body>
<input type="button" value ="点我一次定时" οnclick="ooo()">
  </body>


js 15.html


<script type="text/javascript">
//每隔一秒出现一个数。随时可以终止计数。
var timeId = setInterval("count()", 1000);
var sec = 0;
function count(){
document.getElementById("num").innerHTML = sec++;
}

function stopClick(){
clearInterval(timeId);
}

</script>
  </head>
  
  <body>
<font color ="color" id="num">0</font>秒钟
<input type="button" value = "停止计时" οnclick="stopClick()"  >
 </body>

js 16.html


<script type="text/javascript">
//验证密码。如果密码长度太小,鼠标焦点重新回到输入框
function check(object){
if(object.value.length<=4){
alert("the length of password is too short");
object.focus();
object.select();//选中输入的文字
}
}
</script>
  </head>
  
  <body>

密码:<input type = "password" onblur ="check(this)">

  </body>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值