Thursday, 21 November 2013

Placeholder IE using jquery for html5

 .placeholder { color:#999; }

<script src="">
 // A jQuery based placeholder polyfill
  function add() {
    if($(this).val() === ''){

  function remove() {
    if($(this).val() === $(this).attr('placeholder')){

  // Create a dummy element for feature detection
  if (!('placeholder' in $('<input>')[0])) {

    // Select the elements that have a placeholder attribute
    $('input[placeholder], textarea[placeholder]').blur(add).focus(remove).each(add);

    // Remove the placeholder text before the form is submitted
      $(this).find('input[placeholder], textarea[placeholder]').each(remove);

 <input type='text' name='email' placeholder='Email Address'/>
 <input type='password' name='password' placeholder='Password'/>

No comments:

Post a Comment