MiguelRivero
MiguelRivero

Reputation: 137

DIV doesn't get mouse events

I have a invisible div that on top z-index which I want to act as a clicktag button. But it does not get any mouse event I try to associate with it. Neither it does show the hand pointer specified with css.

This is the example: http://www.miguelrivero.net/test/MS-20_mini/index.html

As you can see I'm using this simple code (just focus on console.log's):

function bgExitHandler(e) {
    Enabler.exit("Background Exit");
    console.log("click");
}

function onMouseHandler(e) {
    console.log("click");
}

document.getElementById("bg-exit").addEventListener("click", bgExitHandler, false);
document.getElementById("bg-exit").addEventListener("onmouseover", onMouseHandler, false);

This is the css:

#bg-exit {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0px;
    left: 0px;
    cursor: pointer;
    opacity: 0;
}

Any light on this, please?

Thanks!

Upvotes: 0

Views: 454

Answers (1)

techfoobar
techfoobar

Reputation: 66663

If you are using addEventListener, the name of the event is just mouseover, not onmouseover:

i.e.

document.getElementById("bg-exit").addEventListener("mouseover", onMouseHandler, false);

Upvotes: 1

Related Questions