Changing A Text Field Based On div mouse event - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Div

Description

Changing A Text Field Based On div mouse event

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function change(x) {/*from   ww w. jav  a  2s  . co m*/
    document.getElementById("mybox").value = "Changed by " + x;
}

      </script> 
   </head> 
   <body> 
      <input type="text" value="" id="mybox" size="100">
      <br> 
      <input type="button" value="Button Click" onClick="change('button')">
      <br> 
      <div onmouseover="change('OnMouseOver')" onmouseout="change('OnMouseOut')">
          Some div
      </div>  
   </body>
</html>

Related Tutorials