当前位置: 代码迷 >> Web前端 >> (四)事件处理――(7)简单事件(Simple events)
  详细解决方案

(四)事件处理――(7)简单事件(Simple events)

热度:312   发布时间:2013-10-15 16:47:37.0
(4)事件处理――(7)简单事件(Simple events)

There are many other times, apart from the loading of the page, at which we might want to perform a task. Just as JavaScript allows us to intercept the page load event with <body onload="">or window.onload, it provides similar hooks for user-initiated events such as mouse clicks (onclick), form fields being modified (onchange), and windows 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对这些方法也提供了高级的处理方法。

  相关解决方案