placeholder shim

测试使用漂浮的label标签来弥补placeholder功能

by lmk123

HTML

<input id="test" placeholder="测试">

JavaScript

var $test = $('#test');
var h = $test.outerHeight();
var w = $test.outerWidth();
var offset = $test.offset();

var $label = $('<label for="'+$test[0].id+'">'+$test.attr('placeholder')+'</label>').appendTo('body');

$label.css({
    width:w,
    height:h,
position: 'absolute',
    zIndex:1,
    left: offset.left,
    top: offset.top,
    cursor: 'text'
});