I studied this issue today and spread some knowledge.
Method 1:
Trigger events through mouseover and mouseout to determine whether the mouse is in the area. But the limitation of this method is that the mouseover, or mouseout, or mouseleave events must be triggered to know.
function chkIn()
{
div_1 .innerText = "Now you move the mouse into the layer!";
div_1.style.font = "normal black";
}
function chkOut()
{
div_1.innerText = "Now you move the mouse out of the layer!";
div_1.style.font = "bold red";
}
onMouseOver="chkIn()" onMouseOut="chkOut()">This is a DIV
Method 2:
function checkIn(e){
var x=window.event.clientX;
var y=window.event.clientY;
var str= ' ';
for(i=0;i var obj=document.body.children[i];
if(x> obj.offsetLeft
.clientWidth)
offsetTop
🎜> str = ' n '; 🎜>
Method 3:
This method is the simplest and most practical.
Copy code The code is as follows: