Skip to main content

Alert Message on Mouse Hover Over a Div Using JavaScript

Submitted by admin on Thu, 01/06/2022 - 08:40

In this JavaScript tutorial we will learn how to create an alert popup box when user / visitor mouse over (hover) over a div region.

JavaScript Code

Let's create a JavaScript function that will create an alert popup message box.

function boxHover() {
  alert("You have mouse over the box");


Now we will create a div region and call the above function on mouse over (hover).

<div id="box" onmouseover="boxHover()"></div>


Let's give some length and width to our div region.

#box {
  width: 100%;
  height: 300px;
  background: yellow;


Tutorial Category