I am working with a group of SVG elements that are assigned the classes node
and link
. My goal is to determine whether an element contains either the node
or link
class when hovering over any of the SVG components. However, I am encountering an issue where the .hasClass()
method does not seem to be functioning correctly:
$(".node").hover(function(evt){
console.log($(this).attr("class")); //outputs "node"
console.log($(this).hasClass('node')); //returns false
}, function(){console.log("Done");});
Even though the element being hovered on possesses the class node
, as evidenced by
console.log($(this).attr("class"));
, the .hasClass()
evaluation fails inexplicably. What could be causing this discrepancy? Could it be related to the use of SVG?