首页 > 代码库 > js input监听兼容事件

js input监听兼容事件

$(‘#phoneNumber‘).on(‘input‘,function() {
var valueP = $(this).attr(‘value‘);
if(valueP.length == 11){
$(‘#getVerCode‘).removeClass(‘unclick‘);
$(‘.getVerCodeJ‘).css(‘display‘,‘none‘);
}
else{
$(‘#getVerCode‘).addClass(‘unclick‘);
$(‘.getVerCodeJ‘).css(‘display‘,‘block‘);
}
});

//for ie
if(document.all){
$(‘#phoneNumber‘).each(function() {
var that=this;

if(this.attachEvent) {
this.attachEvent(‘onpropertychange‘,function(e) {
if(e.propertyName!=‘value‘) return;
$(that).trigger(‘input‘);

var valueP = $(this).attr(‘value‘);
if(valueP.length == 11){
$(‘#getVerCode‘).removeClass(‘unclick‘);
$(‘.getVerCodeJ‘).css(‘display‘,‘none‘);
}
else{
$(‘#getVerCode‘).addClass(‘unclick‘);
$(‘.getVerCodeJ‘).css(‘display‘,‘block‘);
}
});
}
})
}

js input监听兼容事件