javascript - onMouseOver requires click before becoming active -


i have problem onmouseover event on div. have searched forums , tried apply of solutions proposed here similar events, have not found working yet. simple, cannot figure out myself; searching in wrong direction. has tips?

function toggleheight (e, maxheight) {     e = document.getelementbyid("small");      if(e.style.height != '1.2em') {         e.style.height = '1.2em';      }   else {         e.style.height = maxheight + 'px';     } } 

html

<a href="#!" onmouseover="toggleheight(this,180); return false" style="display:block;">menu</a> 

i dont know method , have done many mistake here code of want mean want change height of div , why have written a tag when have mentioned div tag before... here code. go ahead , copy code , paste in code editor... , working, tested this...

    <html>     <style type="text/css">     #link{         background-color: lime;         width:200px;     }            </style>     <script type="text/javascript">          var toogleh = function(h){             //alert("sanmevg");             var x = document.getelementbyid("link");             x.style.height = h;         };          var tooglea = function(a){             var v = document.getelementbyid("link");             v.style.height = a;             };      </script>     <body>       <div id="link" onmouseover ="toogleh('100');" onmouseout="tooglea('20');">sanmveg</div>     </body>  </html>  

suggestions:

1) in tag when write toogleheight must quote height in single quote. remember e.style.height = '180' not e.style.height = 180 means must write string. if want css change such e.style.backgroundcolor= "lime". when pass parameters when type attribute tag such change css must type onmouseover=" toogleheight('180');" not onmouseover=" toogleheight(180);, watch quote around 180 because told earlier must give sting javascript containing number or words change tag's css.

2) use px insted of em because of reasons.. in code have written e.style.height = maxheight + 'px'; dont write px because in css width:200px; same width:200;. means should write e.style.height = maxheight;


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -