Skip to content

Instantly share code, notes, and snippets.

@mozz100
Created March 21, 2012 10:17
Show Gist options
  • Save mozz100/2145983 to your computer and use it in GitHub Desktop.
Save mozz100/2145983 to your computer and use it in GitHub Desktop.
Simulate 'placeholder' with Javascript
// clear the email address field when the user clicks into it
function clickClear(e) {
if (e.value == 'Your email address') { // text must match the default value attribute on the <input> tag
e.value = '';
}
}
<!-- here's the html snippet. The important bits are the value and onfocus attributes -->
<input name="Email" id="Email"
type="text" value="Your email address"
maxlength="255" tabindex="2"
onfocus="clickClear(this);" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment