jquery 设置占位符
<script type="text/javascript">
$(document).ready(function(){
$('.inputfield').each(function(){
$(this).val('');
add_placeholder($(this));
})
$('.inputfield').focus(function(){
remove_placeholder($(this));
}).blur(function(){
add_placeholder($(this));
}).blur();
});
function add_placeholder(field)
{
var placeholder = field.attr('name');
if(field.val() == '')
{
field.val(placeholder);
field.addClass('placeholder');
}
}
function remove_placeholder(field)
{
var placeholder = field.attr('name');
if(field.val() == placeholder)
{
field.val('');
field.removeClass('placeholder');
}
}
</script>