-1

I have the following code, which causes an error below. How do I use JQuery on with hover correctly?

The code:

// Hover on the view filters
$('body').on('hover', '#viewfilter', function(event)
{
    $('#filterblock').show();
},
function(event)
{
    $('#filterblock').hide();
});

There is no error but the show part doesn't seem to be firing.

cdub
  • 22,735
  • 52
  • 164
  • 287

2 Answers2

1

You code looks ok, you can see the demo Joe Buckle fixed with your code.

Your error must be in some other part of the code.

The only suggestion I have is that you use mouseenter instead, you can read here about it.

Community
  • 1
  • 1
Sergio
  • 27,998
  • 10
  • 81
  • 130
0

You've tried to add the eventListener to multiple "view filters" using '#viewfilter'.

This isn't possible because # is the selector for ID's. You can use a className and then call it using '.viewfilters'. This is probably the issue, but without more code it's impossible to be sure.