0

I'm ajaxing some search results onto a page, and trying to do stuff when the user hovers over results. Here's what I've got:

$(".preview").live("hover", function(){ console.log('hovered');} )

Each of the results has the class "preview". Why isn't anything happening?

Edit: Here's where the HTML is coming from:

var preview="<img class='previews' src='http://i.ytimg.com/vi/"+vid+"/default.jpg' />  ";
blueintegral
  • 1,253
  • 5
  • 20
  • 31
  • 1
    Check if this can help you http://stackoverflow.com/questions/2262480/jquery-live-hover – Rond Aug 20 '11 at 22:00
  • 1
    If you are using jQuery 1.4.1 or higher (which allows you to use `hover` with the `.live()` function, then I see nothing wrong with this jQuery code. The issue would likely be with your HTML which you haven't shared. – jfriend00 Aug 20 '11 at 22:01

1 Answers1

2

Your selector is for the class "preview", and your actual html is with the class "previews": Your selector will never match the element ;)

Tobias P.
  • 4,537
  • 2
  • 29
  • 36
  • @aloishis Well, sometimes it's nice for the problem to be that simple. You should be glad you didn't have to do anything complicated. – Peter Olson Aug 20 '11 at 22:09