Im using this code for my inputs:
$(document).ready(function(){
$('.add-news').each( function () {
$(this).val($(this).attr('defaultValue'));
$(this).css({'color':'#686868' , 'font-size':'11px', 'font-weight':'bold'});
});
$('.add-news').focus(function(){
if ( $(this).val() == $(this).attr('defaultValue') ){
$(this).val('');
$(this).css({'color':'#686868' , 'font-size':'11px' ,'font-weight':'bold'});
}
});
$('.add-news').blur(function(){
if ($(this).val() == '' ){
$(this).val($(this).attr('defaultValue'));
$(this).css({'color':'#686868' , 'font-size':'11px', 'font-weight':'bold'});
}
});
});
But in post, It posts 'defaultValue' not $_POST['name']. How can I avoid this? Thanks in advance
$(this)in your various iterator and event handler functions, you're calling a series of functions and doing a couple of memory allocations. Sure, modern computers are fast, but let's throw 'em a bone, eh? :-) Consider doing onevar $this = $(this);at the top of each of those functions and then using$thisthroughout, like this. FWIW.