标签:input function this 不兼容 ie9 bsp tee var 判断
/*
IE9placeholder支持
*/
if(!placeholderSupport()){ // 判断浏览器是否支持 placeholder
$(‘[placeholder]‘).focus(function() {
var input = $(this);
if (input.val() == input.attr(‘placeholder‘)) {
input.val(‘‘);
input.removeClass(‘placeholder‘);
}
}).blur(function() {
var input = $(this);
if (input.val() == ‘‘ || input.val() == input.attr(‘placeholder‘)) {
input.addClass(‘placeholder‘);
input.val(input.attr(‘placeholder‘));
}
}).blur();
};
function placeholderSupport() {
return ‘placeholder‘ in document.createElement(‘input‘);
}
input的placeholder在ie9下不兼容的结局办法。
标签:input function this 不兼容 ie9 bsp tee var 判断
原文地址:https://www.cnblogs.com/quitpoison/p/8794254.html