简体   繁体   English

未捕获的错误:语法错误,无法识别的表达式:悬停

[英]Uncaught Error: Syntax error, unrecognized expression: hover

Here is the JSFidle to the problem: http://jsfiddle.net/LRTh3/36/ 这是解决该问题的JSFidle: http : //jsfiddle.net/LRTh3/36/

$('div.boxes').mousedown(function (event) {

    // Error on this line
    var inner_box = $(".box").is(":hover");

    if ( inner_box == true ) {

        alert("blue,gree,pink was clicked");
    }

    else alert("You mousedowned on the red box");

});​

console: Uncaught Error: Syntax error, unrecognized expression: hover 

Works if only one ".box" layer is presented. 如果仅显示一个 “ .box”层,则可以使用。 Is this a bug? 这是错误吗? How would I fix this? 我该如何解决?

$('div.boxes').mousedown(function (event) {

// Error on this line
var $target = $(event.target);    
if (  $target.is(".box")) {

    alert("blue,gree,pink was clicked");
}

else alert("You mousedowned on the red box");


});​

I lifted it from jQuery API doc 我从jQuery API文档中删除了它

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

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