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;



Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.