Javascript examples for DOM HTML Element:Form Event
Make a background disappear on user input, change its background to red
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <input type="text" style="background: green" onkeyup="modifyBackground(this)"> <script type="text/javascript"> function modifyBackground(elem){/* w ww. j a v a2 s . c o m*/ if( elem.value !== "" ){ elem.style.background = "red"; } else { elem.style.background = "green"; } } </script> </body> </html>