Delete value of search bar text input when clicked - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Delete value of search bar text input when clicked

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 searchbarClicked() {//w  ww  .j  a  v a 2  s  .  c  o  m
document.getElementById('searchbar').value = '';
}

      </script> 
   </head> 
   <body> 
      <input type="text" id="searchbar" name="searchbar" value="search..." onclick="searchbarClicked()"> 
      <input type="submit" value="Search" name="search">
      <br>  
   </body>
</html>

Related Tutorials