这是问题的 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
如果仅显示一个“.box”层,则有效。这是一个错误吗?我将如何解决这个问题?
最佳答案
$('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");
});
我从 jQuery API doc 中提取了它
关于javascript - 未捕获错误 : Syntax error, 无法识别的表达式:悬停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10704183/