Kivylius
Kivylius

Reputation: 6547

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?

Upvotes: 2

Views: 4689

Answers (1)

Todd Murray
Todd Murray

Reputation: 423

$('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

Upvotes: 1

Related Questions