PHP Classes

File: jquery_placeholder_fallback.js

Recommend this page to a friend!
  Classes of Kabir Hossain   PHP CodeIgniter Tips Tricks   jquery_placeholder_fallback.js   Download  
File: jquery_placeholder_fallback.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP CodeIgniter Tips Tricks
Collection of tips and examples to use CodeIgniter
Author: By
Last change:
Date: 16 days ago
Size: 782 bytes
 

Contents

Class file image Download
$(document).ready(function() { if ( !("placeholder" in document.createElement("input")) ) { $("input[placeholder], textarea[placeholder]").each(function() { var val = $(this).attr("placeholder"); if ( this.value == "" ) { this.value = val; } $(this).focus(function() { if ( this.value == val ) { this.value = ""; } }).blur(function() { if ( $.trim(this.value) == "" ) { this.value = val; } }) }); // Clear default placeholder values on form submit $('form').submit(function() { $(this).find("input[placeholder], textarea[placeholder]").each(function() { if ( this.value == $(this).attr("placeholder") ) { this.value = ""; } }); }); } });