Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5932161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:47:47+00:00 2026-05-22T14:47:47+00:00

Hey, I’m trying to add a mousemove and click event to an SVG Raphael

  • 0

Hey, I’m trying to add a mousemove and click event to an SVG Raphael Rectangle:

Fiddle: http://jsfiddle.net/neuroflux/nXKbW/1/

Code:

tile = ctx.rect(x*10,y*(i*10),10,10).attr({
    fill:'#000000',
    stroke: '#ffffff'
});
tile.mouseover(function(e) {
    pX = e.pageX;
    pY = e.pageY;
});
tile.click(function() {
    console.log('x: '+pX+'| y:'+pY);
});

Obviously, for some reason this doesn’t function – I get no output onClick :'(

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:47:48+00:00Added an answer on May 22, 2026 at 2:47 pm

    Ok I’ve got the click function to work. Finally ^_^.

    <!DOCTYPE html>
    <html>
        <head>
            <title></title>
            <script type="text/javascript" src="https://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"></script>
            <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
            <script type="text/javascript">
                /* GLOBAL VARIABLES */
                var drawFrames;
                var canvas;
                var ctx;
                var universe = new Array();
                var tile;
                var pX,pY = 0;
    
                universe = (
                    [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
                    [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
                    [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
                    [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
                    [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
                    [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
                    [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
                    [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
                    [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],
                    [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]]
                );
    
                /* WINDOW LOAD */
                window.onload = function() {
                    init();
                }
    
                /* INITIALISATION */
                function init() {
                    ctx = Raphael(10, 50, 320, 200);
                    drawFrames = setInterval(drawFrame, 40);
                }
    
                /* FRAME RENDER LOOP */
                function drawFrame() {
                    //ctx.clear();
                    for (var x = 0; x < universe.length; x++) {
                        for (var y = 0; y < universe[x].length; y++) {
                            for (var i= 0; i < 11; i++) {
                                tile = ctx.rect(x*10,y*(i*10),10,10).attr({
                                    fill:'#000000',
                                    stroke: '#ffffff'
                                }).click(function(e) {
                            console.log('x: '+e.pageX+'| y:'+e.pageY);
                            })
                        }
                    }
    
                }
            }
            </script>
        </head>
        <body>
            <canvas id="main" width="800" height="600">
                <h1>No Support I'm Afraid...</h1>
            </canvas>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all i have a JSFiddle that i have been working on with trying
Hey guys I'm trying to add an iframe to a page using append. In
Hey guys I'm following the rails tutorial found here http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/ and I've gotten to
Hey folks I am trying to implement a search functionality in a website using
hey there i'm trying to calculate execution time of a simple multithreaded programme on
Hey all i am trying to figure out what i am doing incorrectly here.
Hey trying to get a validation check working on a boolean field called 'activated'.
hey guys I have the follow code in js: $(document).ready(function(){ $(.replyLink).click(function(){ $(#form-to-+this.id).html(htmlForm()).toggle(500); return false;
Hey I'm having a problem trying to figure this out: Lets start out with
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.