Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing object with an eventListener

Status
Not open for further replies.

oneillc9

Programmer
Mar 1, 2005
2
IE
Hi,

Is it possible to pass the object 'obj' like so and still be able to access the event properties:

this.addEventListener('mousedown', this.doSomething(obj), false);

and in the function 'doSomething', still be able to access the event properties?

for example:

doSomething:function(obj, e){
alert(obj); //should print '[object HTMLDivElement]'
alert(e); //hopefully print out '[object mouseEvent]'
}

I need to access both the object passed and the event properties.

Thanks in advance
 
What sort of 'obj' are we talking about? The one that fired the event should be available through event.srcElement.

Other than that... no, you cannot supply function parameters when using addEventListener.

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Enable Apps
 
Thank you. I eventually copped that I could get access through the event.target statement like you said. From there I was able to hop up and down the element tree and get at the elements I needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top