Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-27-2011, 02:40 PM   PM User | #1
yasirjamal
New Coder

 
Join Date: Feb 2009
Posts: 25
Thanks: 2
Thanked 0 Times in 0 Posts
yasirjamal has a little shameless behaviour in the past
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
yasirjamal is offline   Reply With Quote
Old 10-27-2011, 02:56 PM   PM User | #2
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,306
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
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
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa is offline   Reply With Quote
Old 10-30-2011, 02:57 PM   PM User | #3
yasirjamal
New Coder

 
Join Date: Feb 2009
Posts: 25
Thanks: 2
Thanked 0 Times in 0 Posts
yasirjamal has a little shameless behaviour in the past
I am using this code.

Quote:
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('');
});
}
});
yasirjamal is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:34 PM.


Advertisement
Log in to turn off these ads.