Getting class of SVG element in Javascript

J

Jacqueline Snook

Hi,

I am working on a website that uses a SVG diagram with multiple
polygons (to represent rooms in a hotel). Each polygon has a class to
represent whether the room is single or double. In a separate
javascript file, I need to do a different action depending on the
class. How do I read the class in the Javascript file. I tried using
getAttribute("class"), but this does not work - IE comes up with an
error stating 'The object doesn't support this property or method'.

Any help would be greatly appreciated as this is doing my head in!!

Jacqueline
 
M

Martin Honnen

Jacqueline Snook wrote:

I am working on a website that uses a SVG diagram with multiple
polygons (to represent rooms in a hotel). Each polygon has a class to
represent whether the room is single or double. In a separate
javascript file, I need to do a different action depending on the
class. How do I read the class in the Javascript file. I tried using
getAttribute("class"), but this does not work - IE comes up with an
error stating 'The object doesn't support this property or method'.

Maybe you can give some more information. What do you mean by "each
polygon has a class", do you use a CSS class attribute on the SVG
element, or are you talking about some object-oriented class you have
implemented with JavaScript?
As for your script file, is that embedded in the SVG document or in a
HTML page embedding the SVG document?
Which SVG plugin are you using with IE?
 
T

Thomas Meinike

Jacqueline said:
I am working on a website that uses a SVG diagram with multiple
polygons (to represent rooms in a hotel). Each polygon has a class to
represent whether the room is single or double. In a separate
javascript file, I need to do a different action depending on the
class. How do I read the class in the Javascript file. I tried using
getAttribute("class"), but this does not work ...

Try this: <http://svglbc.datenverdrahten.de/?code=klassen_tauschen>

cu, Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top