本文介绍了Javascript键码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好, i有类似下面的javascript代码, 如果( event .keycode!= 37 && event .keycode!= 39 ) { var phoneNumber = $( #phoneNumber)VAL(); if (phoneNumber.length < 1 && event .keyCode!= 48 ) $( #phoneNumber)。val( 0 ) else if ((phoneNumber.length < 2 && event .keyCode == 48 )) event .preventDefault(); else $( #phoneNumber)。val(phoneNumber)} 键码37 =左箭头,键码39 =右箭头,但是当我在键盘上按下这些键时,如果正在执行块之间,我正在使用chrome浏览器,我也使用下面的if语句, if ( event .keycode!= 37 || event .keycode!= 39 ) { var phoneNumber = $( #phoneNumber )VAL(); if (phoneNumber.length < 1 && event .keyCode!= 48 ) $( #phoneNumber)。val( 0 ) else if ((phoneNumber.length < 2 && event .keyCode == 48 )) event .preventDefault(); else $( #phoneNumber)。val(phoneNumber)} 紧急帮助非常感谢, 谢谢大家。解决方案 ( #phoneNumber的)VAL(); if (phoneNumber.length < 1 && event .keyCode!= 48 ) ( #phoneNumber)。val( 0 ) else if ((phoneNumber.length < 2 && event .keyCode == 48 )) event .preventDefault(); else ( #phoneNumber)。val(phoneNumber)} keycode 37 =左箭头,键码39 =右箭头,但是当我在键盘条件下按下这些键时,如果正在执行块,我使用的是Chrome浏览器,我也使用了下面的if语句, if ( event .keycode!= 37 || event .keycode!= 39 ) { var phoneNumber = Hi everyone,i have a javascript code like below,if (event.keycode != 37 && event.keycode != 39){ var phoneNumber = $("#phoneNumber").val(); if (phoneNumber.length < 1 && event.keyCode != 48) $("#phoneNumber").val(0) else if ((phoneNumber.length < 2 && event.keyCode == 48) ) event.preventDefault(); else $("#phoneNumber").val(phoneNumber)}keycode 37 = left arrow, keycode 39 = right arrow but when i pressed these keys on keyboard condition which is between if block being executed, i am using chrome browser, also i used the if statement below,if (event.keycode != 37 || event.keycode != 39){ var phoneNumber = $("#phoneNumber").val(); if (phoneNumber.length < 1 && event.keyCode != 48) $("#phoneNumber").val(0) else if ((phoneNumber.length < 2 && event.keyCode == 48) ) event.preventDefault(); else $("#phoneNumber").val(phoneNumber)}urgent helps greatly appreciated,Thanks everybody. 解决方案 ("#phoneNumber").val(); if (phoneNumber.length < 1 && event.keyCode != 48)("#phoneNumber").val(0) else if ((phoneNumber.length < 2 && event.keyCode == 48) ) event.preventDefault(); else("#phoneNumber").val(phoneNumber)}keycode 37 = left arrow, keycode 39 = right arrow but when i pressed these keys on keyboard condition which is between if block being executed, i am using chrome browser, also i used the if statement below,if (event.keycode != 37 || event.keycode != 39){ var phoneNumber = 这篇关于Javascript键码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-12 03:22