Retreiving Fields like id or classname from target field of an event

Topics: General
Feb 6, 2013 at 3:14 PM
When an event is raised it's target field is an EventTarget. The EventTarget only supports three methods, and doesn't support all the fields that I would see as the result of a click event, such as id, className, etc.

What object type should I be using for an event parameter in an event handler function?
Feb 7, 2013 at 8:42 AM
Edited Feb 7, 2013 at 9:14 AM

One needs to cast the event target (assuming HTML):
        public foo(event: Event) {

            var target = <HTMLElement>;
            var className = target.className;
The TypeScript definition appears to be correct. See the W3C spec.
Feb 7, 2013 at 10:05 AM
Interesting, thanks. I had come across that spec as well. It's funny that using a language that abstracts JavaScript has forced me to learn JavaScript better than before.