[thelist] adding an event to a DOM dynamically added row

Joshua Olson joshua at waetech.com
Tue Mar 18 11:20:41 CST 2003


----- Original Message ----- 
From: "Tom Dell'Aringa" <pixelmech at yahoo.com>
Sent: Friday, March 14, 2003 12:56 PM


> Hi all,
> 
> I am adding rows to a table with the DOM. They now want to add an
> onclick event as well. They were trying setAttribute() with no
> success. Anyone know how we could accomplish this? Here is a snippet
> of how we are doing it:

Tom,

Give this a whirl:

http://www.doxdesk.com/software/js/event.html

If that doesn't work for you, here's something I do:

function myevent()
{
  alert('hi');
  // I could access the attribues of the tag this function
  // is attached to using the "this" reference.
  alert(this.getAttribute('id'));
}

var new_elements = document.createElement('TR');
new_element.onclick = myevent;

HTH,

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com
706.210.0168



More information about the thelist mailing list