| | |
onmouseover and out validation
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Use the eventListener, instead of assigning it directly on those tags that you have mentioned. The only elements that will validates with those events, are the —
And be sure to use only elements that is valid in the DOCTYPE that you are using.
<!-- <a> <img .../> <form><elements></form> <area> --> .And be sure to use only elements that is valid in the DOCTYPE that you are using.
why use javascript for this ? CSS is perfectly capable of doing this without the scripting overhead.
css Syntax (Toggle Plain Text)
/* Example changing a td elements background colour */ td { background-color:transparent; } td:hover { background-color:yellow; } /* Example changing a div's background image */ div { background:transparent url('some_image.jpg'); } div:hover { background:transparent url('another_image.jpg'); }
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Here a simple demo to get you started.
You can validate this entry with W3Cs markup validatation tool's via direct input. Just copy paste the whole code:
You can validate this entry with W3Cs markup validatation tool's via direct input. Just copy paste the whole code:
javascript Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="X-UA-Compatible" content="IE=5; IE=EmulateIE7" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <title>JavaScript DEMO</title> <style type="text/css" charset="utf-8" media="screen,handheld"> /* <![CDATA[ */ body, div, table, td, th { font: normal normal normal 90%/1.4 "Trebuchet MS", Tahoma, Verdana, Helvetica, Arial, Sans-Serif; color: #000; text-align: center } div { height auto; margin: 5em auto 5em auto; min-height: 200px; text-align: left; width: 95%; } div.red { background-color: #E00; } div.white { background-color: #fff; } /* ]]> */ </style> <script type="text/javascript"> /* <![CDATA[ */ var div; var my = function() { function red() { if ( document.all ) { document.all.myDiv.className = "red"; } else if ( document.getElementById ) { document.getElementById("myDiv").className = "red"; } } function white() { if ( document.all ) { document.all.myDiv.className = "white"; } else if ( document.getElementById ) { document.getElementById("myDiv").className = "white"; } } function addEvents() { div = ( document.all ) ? document.all.myDiv : document.getElementById("myDiv"); if ( document.attachEvent ) { div.attachEvent("onmouseover",red); div.attachEvent("onmouseout",white); } else if ( document.addEventListener ) { div.addEventListener("mouseover",red,false); div.addEventListener("mouseout",white,false); } } return { colors : addEvents } }(); if ( window.attachEvent ) window.attachEvent("onload",my.colors); else if ( window.addEventListener ) window.addEventListener("load",my.colors,false); else window.onload = my.colors; /* ]]> */ </script> </head> <body> <div class="white" id="myDiv">Try MouseOver and MousedOut here!</div> <div id="div1"><a href="#">Div Filler</a></div> </body> </html>
![]() |
Similar Threads
- Dynamically enlarge image on mouseover and mouseout (JavaScript / DHTML / AJAX)
- XML Bug Error. (XML, XSLT and XPATH)
- HTML onMouseOver and Out validation problem (HTML and CSS)
- Really Stuck - ASP/Javascript Form Validation (ASP)
- JavaScript form validation - please help (JavaScript / DHTML / AJAX)
- Validation difficulties *sigh* (ASP.NET)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Dynamic DIV tags don't work.
- Next Thread: how to establish serial port communication using javascript for webpage
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser calendar captchaformproblem cart close codes column css date debugger decimal dependent design dom download dropdown element embed enter error events firefox focus form frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 iframe image() index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp libcurl listbox maps masterpage media menu microsoft mimic mp4 onerror onmouseover paypal php player position post problem programming prototype rating redirect regex safari scale scriptlets search security select software sql starrating synchronous text textarea toggle unicode validation variables w3c webservice website window windowofwords windowsxp xml





