Created
June 12, 2012 08:32
-
-
Save netsi1964/2916198 to your computer and use it in GitHub Desktop.
Netsi1964 HTML SNIPPETS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Netsi1964 HTML SNIPPETS | |
<!-- Simpel default/placeholder value for textarea, require jQuery --> | |
<textarea name="" id="" cols="30" rows="10" placeholder="test">test</textarea> | |
<script type="text/javascript"> | |
$(function() { | |
var test = document.createElement('textarea'); | |
if (!!!('placeholder' in test)) { | |
jQuery('textarea').focus(function() { | |
var $this = $(this); | |
if ($.trim($this.val())===$this.attr('placeholder')) { | |
$this.val(''); | |
} | |
}).blur(function() { | |
var $this = $(this); | |
if ($.trim($this.val()).length===0) { | |
$this.val($this.attr('placeholder')); | |
} | |
}); | |
}; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment