This example demonstrates how to assign an "onmouseover" and "onmouseout" event to a h1 element.
<!DOCTYPE html> <html> <body> <h1 id="demo" onmouseover="mouseOver()" onmouseout="mouseOut()">Mouse over me</h1> <script> function mouseOver() {/*from w w w.j a v a2 s . com*/ 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> |
---|