Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2009
    Posts
    20
    Thanks
    3
    Thanked 0 Times in 0 Posts

    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();

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

    document.getElementById("Mole1").onclick = Mole1X;


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •