I have a set of SVG elements with the classes node
and link
. My program should detect whether an element has the node
class or the link
class upon hovering over any of the SVG elements. However, for some reason, the .hasClass()
doesn't seem to work:
$(".node").hover(function(evt){
console.log($(this).attr("class")); //returns "node"
console.log($(this).hasClass('node')); //returns false
}, function(){console.log("Done");});
So the element I hovered on has the class node
, and jQuery detects that too, as shown by console.log($(this).attr("class"));
, but for some reason the actual .hasClass()
fails. Why is this? Is it failing because of the SVG?