HTML and CSS Reference
In-Depth Information
Figure 15.43 When the mouse is moved over the first paragraph, nothing
happens. The event listener was removed.
EXAMPLE 15.22
<html>
<head><title>Register Multiple Events</title>
<script type="text/javascript">
1
window.onload=function(){
2
var paraHandle1 = document.getElementById("para1");
var paraHandle2 = document.getElementById("para2");
3
paraHandle1.addEventListener('mouseover',highLight, false);
4
paraHandle2.addEventListener('click', function(){
this.style.fontSize="x-large"},false);
5
paraHandle2.addEventListener('mouseover', highLight,false);
6
paraHandle1.removeEventListener('mouseover',
highLight,false);
7
function highLight() { / Closure
8
this.style.backgroundColor ="tan";
this.style.fontFamily ="fantasy";
this.style.fontWeight ="bold";
}
}
</script>
</head>
<body>
9
<p id="para1">
There was an old lady who lived
in a shoe.<br />
Search WWH ::




Custom Search