问题
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?
回答1:
$('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
来源:https://stackoverflow.com/questions/10704183/uncaught-error-syntax-error-unrecognized-expression-hover