`
444878909
  • 浏览: 641195 次
文章分类
社区版块
存档分类
最新评论

(4)事件处理——(7)简单事件(Simple events)

 
阅读更多

There are many other times, apart from the loading of the page, at which we mightwant to perform a task. Just as JavaScript allows us to intercept the page load eventwith <body onload="">or window.onload, it provides similar hooks for user-initiatedevents such as mouse clicks (onclick), form fields being modified (onchange), andwindows changing size (onresize). When assigned directly to elements in the DOM,these hooks have similar drawbacks to the ones we outlined for onload. Therefore,jQuery offers an improved way of handling these events as well.

有很多时候,我们想绑定一些事件,而不仅仅是在加载网页的时候触发。正如js允许我们使用<body onload=''>和window.onload监听网页加载事件,他也提供了相似的拦截器用来对用户事件作出反应,比如鼠标的点击事件(onclick),表单元素被修改(onchange)和窗口大小被修改(onresize)。当我们直接绑定到DOM中的元素上的时候,这些拦截器和之前我们描述过的onload有着相似的缺点。因此,jquery对这些方法也提供了高级的处理方法。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics