`
nbkangta
  • 浏览: 424914 次
  • 性别: Icon_minigender_1
  • 来自: 宁波
社区版块
存档分类
最新评论

JavaScript DOM Model 2 添加multiple handlers

阅读更多
  1. addEventListener(eventType,listener,useCapture)

eventType参数指定handle类型,如”click”,”mouseover”,”keydown”等。

listener参数是函数或者内联函数的引用,传递handle处理的闭包。 

最后一个参数,useCapture是个布尔型变量,一般留为空。 

<html>

  <head>

    <title>DOM Level 2 Events Example</title>

    <script type="text/javascript"

            src="../scripts/jquery-1.2.1.js">

    </script>

    <script type="text/javascript">

      $(function(){                 

        var element = $('#vstar')[0];

        element.addEventListener('click',function(event) {

          say('Whee once!');

        },false);

        element.addEventListener('click',function(event) {

          say('Whee twice!');

        },false);

        element.addEventListener('click',function(event) {

          say('Whee three times!');

        },false);

      });

      function say(text) {

        $('#console').append('<div>'+text+'</div>');

      }

    </script>

  </head>

  <body>

    <img id="vstar" src="vstar.jpg"/>

    <div id="console"></div>

  </body>

</html>

Establishes three event handlers!

分享到:
评论

相关推荐

    Javascript Event Handlers.zip

    Javascript Event Handlers

    flexpaper_handlers.js

    flexpaper_handlers.jsflexpaper_handlers.jsflexpaper_handlers.js

    Test-Driven JavaScript Development

    Throughout this part we will, among other things, learn how to test code that depends on browser API’s, timers, event handlers, DOM manipulation, and asynchronous server requests (i.e., “Ajax”)....

    handlers.js

    handlers.js

    [Head.First.Ajax.2008].Rebecca.M.Riordan.文字版.pdf

    4 Multiple Event Handlers: Two’s Company 139 5 Asynchronous Applications: It’s Like Renewing Your Driver’s License 173 6 The Document Object Model: Web Page Forestry 229 7 Manipulating the DOM: My ...

    Web event handlers

    总结了IE 5 ,页面的所有事件 Dom Event Handlers/Dom 事件处理函数

    javascript权威指南(第六版)

    2. Lexical Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.1 Character Set 21 2.2 Comments 23 2.3 Literals 23 2.4 ...

    JavaScript Applications with Node.js, React, React Native and MongoDB

    JavaScript Applications with Node.js, React, React Native and MongoDB: Design, code, test, deploy and manage in Amazon AWS By 作者: Eric Bush ISBN-10 书号: 0997196661 ISBN-13 书号: 9780997196665 出版...

    Python库 | django-ohm2-handlers-light-0.1.19.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:django-ohm2-handlers-light-0.1.19.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    react-handlers:调用React事件处理程序列表

    var handlers = require ( 'react-handlers' ) ; render = function ( ) { return &lt; button onClick = { handlers ( this . doThis , this . doThat ) } &gt; Clack &lt; / button &gt; } 触发事件时,将按顺序...

    Understanding JavaScript Promises 理解JavaScript Promises

    What you’ll learn: Which parts of promises are synchronous and which are asynchronous How to effectively use promise chains to simplify ...What happens to rejected promises without rejection handlers

    Apache Axis2 Web Services, 2nd Edition.pdf

    Chapter 3, Axis2 XML Model (AXIOM) - Learn about the heart of a web service framework and learning more about XML processing in Axis2. Chapter 4, Execution Chain - Learn how to extend the core ...

    WEB开发人员参考大全_最完整的HTML.CSS与JAVASCRIPT工具书

    this reference alphabetically lists every HTML tag supported by Netscape Navigator and Internet Explorer, along with their attributes, event handlers, CSS and JavaScript style properties, and much ...

    开源项目-gorilla-handlers.zip

    开源项目-gorilla-handlers.zip,gorilla/handlers: A collection of useful handlers for Go's net/http package

    raphael 1.5.2

    This means every graphical object you create is also a DOM object, so you can attach JavaScript event handlers or modify them later. Raphaël’s goal is to provide an adapter that will make drawing ...

    Python logging模块handlers用法详解

    主要介绍了Python logging模块handlers用法详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

    Python库 | pollination_handlers-0.5.0-py2.py3-none-any.whl

    资源分类:Python库 所属语言:Python 资源全名:pollination_handlers-0.5.0-py2.py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    UploadSwf批量上传文件

    主要特点: * 可以同时上传多个文件;...在使用SWFUpload之前,请确认你具备一定的JavaScript和DOM知识。在实际开发中,大部分的错误都是由于错误的设置和低劣的Event Handlers处理程序所造成的。

    c#描述swfupload上传实例

    SWFUpload的主要特点  * 可以同时上传多个文件;... 在使用SWFUpload之前,请确认你具备一定的JavaScript和DOM知识。在实际开发中,大部分的错误都是由于错误的设置和低劣的Event Handlers处理程序所造成的。

Global site tag (gtag.js) - Google Analytics