Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    25
    Thanks
    2
    Thanked 0 Times in 0 Posts

    jquery.placeholder

    Hi,

    I am using jqurey placeholder and it's working fine the problem is this is only for "input" i need to do same for my textarea.

    Any suggestions?

    Thanks in advance

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    did you use the proper selectors liek the example on the site

    :
    Code:
     $('input[placeholder],textarea[placeholder]').placeholder();
    if you are jsut using

    Code:
    $('input[placeholder]').placeholder();
    it wont bind to textareas

  • #3
    New Coder
    Join Date
    Feb 2009
    Posts
    25
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I am using this code.

    jQuery(function() {
    jQuery.support.placeholder = false;
    test = document.createElement('input');
    if('placeholder' in test) jQuery.support.placeholder = true;
    });
    // This adds placeholder support to browsers that wouldn't otherwise support it.
    $(function() {
    if(!$.support.placeholder) {
    var active = document.activeElement;
    $(':text').focus(function () {
    if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
    $(this).val('').removeClass('hasPlaceholder');
    }
    }).blur(function () {
    if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
    $(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
    }
    });
    $(':text').blur();
    $(active).focus();
    $('form:eq(0)').submit(function () {
    $(':text.hasPlaceholder').val('');
    });
    }
    });


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •