js input监听兼容事件

时间:2023-03-09 03:48:26
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');
}
});
}
})
}