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

  • SEARCH
  • Home
  • 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 7173015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:44:08+00:00 2026-05-28T15:44:08+00:00

I have this code: $(‘#whatever .item’).each(function() { var canvas = document.getElementById(‘whatever’); var ctx =

  • 0

I have this code:

$('#whatever .item').each(function() {
    var canvas = document.getElementById('whatever');
    var ctx = canvas.getContext('2d');
    /* Drawing */


    $(document).mousemove(function(e) {

        mouseY = e.pageY;
        mouseX = e.pageX;       


            if(ctx.isPointInPath(mouseX, mouseY)) {
             alert("HEY!");     

            }

     });
});

I have multiple span tags in the canvas. I’m then using the span tags to create images on a canvas, using ‘each’. So I assumed if I added a mousemove it would add one for each span tag, but it doesn’t. Any ideas?

  • 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-28T15:44:10+00:00Added an answer on May 28, 2026 at 3:44 pm

    If I understand you correctly, and I might not, you can’t do things the way you are now.

    Right now you have multiple <span> tags inside of a <canvas> tag that represent data that is being drawn to the canvas. You then want something to happen when you hover over that data that is being drawn to the canvas.

    This is not how canvas works. None of those <span> tags show up on the page (except as fallback content) and their mousemove/etc events have no bearing on the canvas surface.

    When you use your span tags to draw images (or whatever data) to the canvas you have to keep track of where you draw them. Then you need only one mousemove event, on the <canvas> itself, that will loop through the list of locations (or paths or rectangles) that you are trying to detect.

    So to attach a mouse event to images drawn on a canvas, you have to keep track of everything drawn yourself. Mouse events on anything except the Canvas itself won’t cut it. All of this you have to write yourself or else use a library. You have indicated that you don’t want to use anymore libraries so here’s a tutorial on learning how to make the canvas interactive (mousedown, mousemove, keeping track of what is drawn, etc).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have this code: var gradient = ctx.createLinearGradient(0,0, 20, 0); gradient.addColorStop(0.8, rgb(250,250,0)); gradient.addColorStop(1, rgb(150,150,0)); ctx.fillStyle
I have this code: dojo.declare(City, null, { constructor : function(cityid, cityinfo){ } }); dojo.declare(TPolyline,
I have this code that I call on each touch event that render an
I have this code: Dim Tasks As New List(Of Task) Tasks.Add(Task.Factory.StartNew(Sub() 'Do whatever End
I have this code var contacts = dr.mktDoctorContacts .GroupBy(x => x.ContactType) .Select(zb => new
I have this code & I've tired using JQuery's appendTo() function to get this
I have this code and I need an explanation on what it does: function
I have this code to parse url string such as ?var=val but when search
I have this code: $('p', 'div.playlist').click(function(e){ if (e.target != this) { val = $(this).parent().attr('songid');
I have this code, but this line has some problem. var dataString = 'name='+name&'id='+id;

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.