good_evening
good_evening

Reputation: 21749

How to ignore class in jQuery?

Here is simple example I did: http://jsfiddle.net/J3rBX/

My purpose: when I mouseover that input, it would give me an alert. Everything seems fine, but when I mouseover that text which has class 'txt', it doesn't give me an alert. What should I do?

Upvotes: 2

Views: 165

Answers (2)

Matthew
Matthew

Reputation: 15962

Just add .txt to the selector:

$(".omg, .txt").bind("mouseover", function() {
       alert("i mouseover'ed omg class");
})

Setting pointer-events: none; on the .txt class also works.

Upvotes: 2

Pointy
Pointy

Reputation: 413757

The problem is that the <span> appears after the <input>, so it's "on top" of the <input> and it effectively blocks the mouse events.

Upvotes: 2

Related Questions