Get ID of HTML Element on mouse hover

0 favourites
  • 3 posts
From the Asset Store
Get ready to dive into a sea of endless excitement with "Dolphin Jump," the thrilling new game that puts you in control
  • I'm populating many thumbnail images on the fly with the "Create sprite image element" event on the HTML Element object. It's all working well but the next step I need to do is when hovering these images with the mouse I want to show that thumbnail bigger in a new window ontop (imagine typical image search).

    There is an action in the HTML Element to find the ID when it's clicked but nothing for hover. When using the mouse object I just get a NAN info from the HTML Element, probably because it's looking at the whole HTML Element object instead of the unique image.

    Any way to get this to work?

  • I think this is possible with custom javascript. It's a new territory for me so looking into that. Does anybody have a good way to add some event listeners for mouse enter and mouse out in JS?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I finally got this working with some Javascript...

    const images = document.getElementsByClassName("searchImage");
    
    for (const image of images) {
    	image.addEventListener("mouseover", () =>
    	{
    		runtime.globalVars.HoverImage = image.id;
    		runtime.globalVars.HoverImageX = image.x
    		runtime.globalVars.HoverImageY = image.y;
    		
    	});
    
    }
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)