subrui
subrui

Reputation: 189

HTML onmouseover and onmouseout

My HTML:

<img id="1" src="imgs/1.jpg" border="0" onmouseover="show(1)" onmouseout="hide()">

My JS:

function show(id) {
makeLayer('LYR1',600,30,300,360,'red',1,1);
}

function hide() {
kill show;
}

Any idea what I'm doing wrong?

What I want to do is: when a user mouse is over that image, it will show a new div layer. When a user mouse is out the image, hide this new layer.

Upvotes: 0

Views: 76

Answers (2)

miyasudokoro
miyasudokoro

Reputation: 1745

Assuming you are using the function makeLayer from http://www.javascripter.net/faq/creating.htm, then the first argument to the function is the id of the layer element that it creates. To get rid of the layer element, you find it using its id and then remove it.

function hide() {
    var layer = document.getElementById('LYR1');
    layer.parentNode.removeChild(layer);
}

I don't know where you got that kill idea from, but it's nowhere near correct.

Upvotes: 1

JQuery does support mouseover and mouseout functions too http://api.jquery.com/mouseover/

Upvotes: 0

Related Questions