Getting class of SVG element in Javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jacqueline Snook

    Getting class of SVG element in Javascript

    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("c lass"), 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
  • Martin Honnen

    #2
    Re: Getting class of SVG element in Javascript



    Jacqueline Snook wrote:

    [color=blue]
    > 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("c lass"), but this does not work - IE comes up with an
    > error stating 'The object doesn't support this property or method'.[/color]

    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?
    --

    Martin Honnen


    Comment

    • Thomas Meinike

      #3
      Re: Getting class of SVG element in Javascript

      Jacqueline Snook wrote:
      [color=blue]
      >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 ...[/color]

      Try this: <http://svglbc.datenver drahten.de/?code=klassen_t auschen>

      cu, Thomas
      --
      SVG - Learning By Coding
      <http://svglbc.datenver drahten.de/>

      Comment

      Working...