Skip to content

Instantly share code, notes, and snippets.

@maxschulze
Created May 23, 2014 15:22
Show Gist options
  • Save maxschulze/5854036a8feef618af78 to your computer and use it in GitHub Desktop.
Save maxschulze/5854036a8feef618af78 to your computer and use it in GitHub Desktop.
placeholder example
$(document).ready ->
$("[placeholder]").focus(->
input = $(this)
if input.val() is input.attr("placeholder")
input.val ""
input.removeClass "placeholder"
).blur(->
input = $(this)
if input.val() is "" or input.val() is input.attr("placeholder")
input.addClass "placeholder"
input.val input.attr("placeholder")
).blur()
$("[placeholder]").parents("form").submit ->
$(this).find("[placeholder]").each ->
input = $(this)
input.val "" if input.val() is input.attr("placeholder")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment