Javascript DOM onmouseout Event via HTML Tag onmouseout attribute

Introduction

This example demonstrates how to assign an "onmouseover" and "onmouseout" event to a h1 element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<h1 id="demo" onmouseover="mouseOver()" onmouseout="mouseOut()">Mouse over me</h1>

<script>
function mouseOver() {// w  ww .j  av a  2s  . c o m
  document.getElementById("demo").style.color = "red";
}

function mouseOut() {
  document.getElementById("demo").style.color = "black";
}
</script>

</body>
</html>
Bubbles:
Cancelable:
Event type:
Supported HTML tags:











Yes
Yes
MouseEvent
All HTML elements, EXCEPT:
<base>,
<bdo>,
<br>,
<head>,
<html>,
<iframe>,
<meta>,
<param>,
<script>,
<style>, and
<title>



PreviousNext

Related