$('#username').keydown(function(){
console.log($(this).val().match(/^0?(13|15|18|14|17)[0-9]{9}$/));
if($(this).val().match(/^0?(13|15|18|14|17)[0-9]{9}$/)){
$(".new-input-span-v1").show();
console.log(11);
} else {
$(".new-input-span-v1").hide();
console.log(22);
}
});
为什么输入手机号码后显示不了,需要$('#username')失去焦点或者再输入一个才执行console.log(11);
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
应该是
keyup
事件吧,keydown
发生在文字显示之前,keyup
显示在文字显示之后keyup
知道啦,用.keyup