简体   繁体   中英

Uncaught Error: Syntax error, unrecognized expression: hover

Here is the JSFidle to the problem: 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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