Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-03-2009, 09:55 PM   PM User | #1
Squishinator
New Coder

 
Join Date: Jun 2009
Posts: 20
Thanks: 3
Thanked 0 Times in 0 Posts
Squishinator is an unknown quantity at this point
Change onclick value

WHat happens is it runs that function no matter what when i do it. Here is my code.

Code:
document.getElementById("Mole1").onclick = Mole1X();
Squishinator is offline   Reply With Quote
Old 07-03-2009, 09:59 PM   PM User | #2
ckeyrouz
Senior Coder

 
ckeyrouz's Avatar
 
Join Date: Jun 2009
Location: Montreal, Canada
Posts: 1,044
Thanks: 5
Thanked 179 Times in 179 Posts
ckeyrouz is on a distinguished road
This is because you should pass the pointer of the function to the onclick event like this:

document.getElementById("Mole1").onclick = Mole1X;
ckeyrouz is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:16 AM.


Advertisement
Log in to turn off these ads.