;!function fixPlaceholder() {
var hasPlaceholder = 'placeholder' in document.createElement('input');
if(!hasPlaceholder) {
$(document).on('blur', '[placeholder]', function () {
if($(this).val() == '') {
$(this).val($(this).attr('placeholder'))
}
}).on('focus', '[placeholder]', function () {
var $this = $(this);
if($this.val() == $this.attr('placeholder')) {
var r = $this.createTextRange();
r.collapse(true);
r.select();
if (typeof($this.onselectstart) != "undefined") {
// IE下禁止元素被选取
$this.onselectstart = new Function("return false");
}
}
}).on('keydown','[placeholder]', function () {
var $this = $(this);
if($this.val() == $this.attr('placeholder')) {
$this.val('');
}
if (typeof($this.onselectstart) != "undefined") {
// IE下禁止元素被选取
$this.onselectstart = new Function("return false");
}
});
$('[placeholder]').blur();
}
}();