Use onMouseOut in Javascript
There are a couple of ways to use onMouseOut in Javascript...
If you've used
onClick or
onMouseOver, then you already know how to use onMouseOut.
You can write the javascript right into the link tag or you can
call a function located elsewhere in your code.
First, we'll write the code right into the link:
<a href="#" onMouseOut="javascript:alert('Thanks for the onMouse!')">Need an onMouse?</a>
-After the onMouseOut tag, we enclose our entire javascript code in double quotation marks.
-We start with the
javascript: to tell the browser we have javascript code coming up.
-We use javascript's built-in
alert method to open an alert box. Since we are inside double quotes, we use single quotes around our message.
Using onMouseOut to call a function is similar and fairly easy:
function sayHey() {
alert('Thanks for the onMouse!');
}
<a href="#" onMouseOut="javascript:sayHey()">Do you need an onMouse?</a>
-First we
created our function sayHey.
-Instead of writing our code in the onMouseOut tag, we just called our newly created function.
Free Copy and Paste Javascript Code:
<script type="text/javascript">
<!--
function sayHey() {
alert('Thanks for the onMouse again!');
}
-->
</script>
<a href="#" onMouseOut="javascript:alert('Thanks for the onMouse!')">On Mouse 1</a>
<a href="#" onMouseOut="javascript:sayHey()">On Mouse 2</a>
Resources:
Use OnMouseOver in Javascript
Use onClick in Javascript
Create a Function in Javascript
Call your Function in Javascript
Opening an Alert Box in Javascript
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
| | | |
Dojo Matthew A. Russell... | | |
| | | |