js事件

<head></head>

<script>

function click_button(){//事件处理程序,弹出提示框

alert('welcome to xiaomang\'s codepen'); }

function mDown(obj) // 按下鼠标 的 事件处理程序

{

obj.style.backgroundColor="#1ec5e5";

obj.innerHTML="release your mouse"

}

function mUp(obj)     
// 松开鼠标 的 事件处理程序
{
obj.style.backgroundColor="green";
obj.innerHTML="press here"
}
function no_empty(x)
{
  if (x.value=="")
  {
    alert('input cannot be empty');
  }

}

</script>

<body align="left"> 

<button οnclick="click_button()">敢不敢点我</button>
move your mouse to here
输入你的名字:<input type="text" οnblur="no_empty(this)"> </body>
常用事件有:
onclick单击
ondblclick双击
onfocus元素获得焦点
onblur元素失去焦点
onmouseover鼠标移到某元素之上
onmouseout鼠标从某元素移开
onmousedown鼠标按钮被按下
onmouseup鼠标按键被松开
onkeydown某个键盘按键被按下
onkeyup某个键盘按键被松开
onkeypress某个键盘按键被按下并松开
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值