Skip to content

Instantly share code, notes, and snippets.

@jnaskali
Created March 8, 2012 10:20
Show Gist options
  • Select an option

  • Save jnaskali/2000163 to your computer and use it in GitHub Desktop.

Select an option

Save jnaskali/2000163 to your computer and use it in GitHub Desktop.
JavaScript: Input onFocus onBlur change
<script type="text/javascript">
function myFocus(element) {
if (element.value == element.defaultValue) {
element.value = '';
}
}
function myBlur(element) {
if (element.value == '') {
element.value = element.defaultValue;
}
}
</script>
<input type="text" id="first" value="Insert text here..." onfocus="myFocus(this);" onblur="myBlur(this);">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment