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 l
The class attribute for HTML element doesn't have the same meaning in SVG.
$("").addClass($(this).attr("class")).hasClass("node")
Or
/(^|\s)node(\s|$)/.test($(this).attr("class"))
for SVG elements.
EDIT .hasClass seems to work just fine (at least in IE9 and FF) http://jsfiddle.net/X6BPX/1/
So the problem could be any combination of the following: a syntax error, using an outdated browser, using an outdated version of jQuery.