/    Sign up×
Community /Pin to ProfileBookmark

Help With Event Handlers

ok right I have this script that creates an icon image and adds assigns a function to an event on this image. You can create as many icons as you want. Now my problem is that I want to be able to identify the element that triggered the function call.

I need a way to pass the element that was clicked on into the updateImageIcon. Here is an example of the code if you can make any sense of it. I know this don’t work but If any one can decipher what I am trying to do and help me out, I would be most appreciative.

function stuff()
{

icon_image = document.getElementById(iconID);
icon_image.onmouseup = updateImageIcon;

}

function updateImageIcon(elementID)
{
icon = document.getElementById(elementID)
alert(icon.src);
}

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Parodious spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...