占位符不能在IE-9中工作,所以我使用下面的代码来占位符。占位符不起作用
jQuery(function() {
debugger;
jQuery.support.placeholder = false;
test = document.createElement('input');
if ('placeholder' in test) jQuery.support.placeholder = true;
});
// This adds placeholder support to browsers that wouldn't otherwise support it.
$(function() {
if (!$.support.placeholder) {
var active = document.activeElement;
$(':text').focus(function() {
if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
$(this).val('').removeClass('hasPlaceholder');
}
}).blur(function() {
if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
}
});
$(':text').blur();
$(active).focus();
$('form:eq(0)').submit(function() {
$(':text.hasPlaceholder').val('');
});
}
});
当我服用测试的价值,它表明我null.How可以得到所有输入标签的细节?
占位符属性将不支持低于IE 10 –
@Deepu貌似OP知道,并试图实现一种变通方法... – Teemu
@Deepu OP的代码是“占位符”支持的一个垫脚... –