www.webdeveloper.com
Results 1 to 5 of 5

Thread: Creating an event,i assign a function with parameters and in this moment its executed

  1. #1
    Join Date
    Jul 2012
    Posts
    11

    Creating an event,i assign a function with parameters and in this moment its executed

    The function that creat this event is
    HTML Code:
    function crearEvento(elemento, evento, funcion) {
          if (elemento.addEventListener) {
                elemento.addEventListener(evento, funcion, false);
          } else {
                elemento.attachEvent("on" + evento, funcion);
          }
    }

    i creat this event thus

    HTML Code:
    crearEvento(elem,'click',dale(elem));
    and the dale function is declared thus
    HTML Code:
    var dale = function (atemp){ alert(atemp.innerHTML);}

    How Can i creat this event to replace the tipically?
    HTML Code:
    <td onClick="dale(this);">

  2. #2
    Join Date
    Jul 2009
    Posts
    45
    (removed)

  3. #3
    Join Date
    Jul 2012
    Posts
    11
    removed? Please explain me this problem. Thank you

  4. #4
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Code:
    crearEvento(elem, 'click', function(){ dale( elem ) } );
    elem must be within scope at that point.

  5. #5
    Join Date
    Jul 2012
    Posts
    11
    Thank you Logic Ali

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles