-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
  • 24,555
  • 57
  • 174
  • 303

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
  • 28,539
  • 11
  • 85
  • 132
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.