简体   繁体   English

未捕获的SyntaxError:意外的字符串

[英]Uncaught SyntaxError: Unexpected string

I'm having difficulty getting the following to work, all I get from Chrome's Console is Uncaught SyntaxError: Unexpected string . 我很难执行以下操作,从Chrome控制台获得的所有内容都是Uncaught SyntaxError: Unexpected string

I have tried tmp = event.keyCode and changing tmp in the if statement to event.keyCode but I cannot identify the problem. 我已经尝试过tmp = event.keyCode并将if语句中的tmp更改为event.keyCode但是我无法确定问题所在。

 function showSearching() { alert ("Hello World"); } $('#search').bind('keydown', function() { tmp = Number(event.keyCode); if ( ( tmp=<"48" && tmp=>"90" ) || ( tmp=<"96" && tmp=>"111" ) || ( tmp=<"186" && tmp=>"222" ) ) { showSearching(); } }); 
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> <input id="search" type="text"> 

Wrong syntax of relational operator in if statement. if语句中关系运算符的语法错误。

change => to >= and =< to <= => to >=更改=> to >= ,将=< to <=

$('#search').bind('keydown', function() {
    tmp = Number(event.keyCode);
    if ((tmp  <= "48" && tmp  >= "90") || (tmp  <= "96" && tmp  >= "111") || (tmp  <= "186" && tmp  >= "222")) {
        showSearching();
    }
});​

=<更改为<=

if ( ( tmp<="48" && tmp>="90" )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM