Jan Šimerda Jan Šimerda - 1 year ago 82
Javascript Question

mouseover is not a function

I am trying to add a class to a specific div after hovering over an item in the navigation. I am using jQuery 3.1.1 from a CDN. And I am getting a

not a function error
. Here's the code:

var navigation = $("nav ul#primary-menu li");
var brands = $("div.brands > div");

navigation[0].mouseover(function() {

navigation[1].mouseover(function() {

navigation[2].mouseover(function() {

navigation[5].mouseover(function() {

Got any ideas?

Answer Source

navigation[0] is not an jQuery object, it's pure html element

to access jQuery methods, you have to use navigation.eq(0) instead (same goes with brands)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download