タグ

JavaScriptとeventに関するyoshiwebのブックマーク (2)

  • jQueryの.bind(), .live(), .delegate()の違い

    The Difference Between jQuery’s .bind(), .live(), and .delegate() - Alfa Jango Blog http://www.alfajango.com/blog/the-difference-between-jquerys-bind-live-and-delegate/ jQueryの.bind(), .live(), .delegate()違いや仕組みの理解、また.delegate()の方が.live()より優れている理由について書かれています。 内容を簡単に書き出すと以下のようなことについて書かれています。 $('a').bind('click', function() { alert("That tickles!") }); .bind()は$(‘a’)に対してイベントを設定してる。 $('a').live('clic

    jQueryの.bind(), .live(), .delegate()の違い
  • イベントに処理を追加する - JavaScript

    たとえば、initOther()という関数をロード時に実行したいとします。 通常は、次のようなコードになると思います。 function initOther () { //何らかの処理 } window.onload = initOther; しかし、すでに window.onload に関数が割り当てられている場合、割り当てられている関数が実行されなくなります。 たとえば、 <body onload="initMain()"> ...</body> とあれば、window.onload = initOther; のために initMain() は実行されません。 そこで、addEventListener() メソッドを使用します。Internet Explorerでは addEventListener() メソッドが使えませんので、代わりに attachEvent() メソッドを使用しま

    yoshiweb
    yoshiweb 2012/07/02
    window.onload
  • 1