1

I have two SVG elements:

<circle r="260.2" fill="#1ABCb6" class="" id="svg_el_obj"></circle>
<circle r="260.2" fill="#1ABCb6" class="" id="svg_el_obj"></circle>

and i want add for them the same cx and cy atributes, so i use each with jquery but i have expected response for only first element, what is wrong?

svg_el_obj.each(function(){
    $(this).attr({
        cx: svg_plain_h/2,
        cy: svg_plain_h/2
    })
});

thx for help.

Lukas
  • 7,384
  • 20
  • 72
  • 127
  • 1
    how do you create svg_el_obj ? check his length, must be one if you only get the first, your error is not in the .attr code, also you not need the each => svg_el_obj.attr({}); – r043v Jun 14 '13 at 00:02
  • 1
    Worth pointing out here. You have the same id for two elements in the same document. The ids must be unique: http://www.w3.org/TR/html401/struct/global.html#h-7.5.2 – veritasetratio Jun 14 '13 at 00:04
  • im creating them by JS, and i have two elements bc i see them in my DOM :) – Lukas Jun 14 '13 at 00:05
  • i have two different ids now and it's not helps – Lukas Jun 14 '13 at 00:19
  • 1
    Here is a fiddle with some additions to fill in the gaps between your description and getting something working. There is an execute button to click to run the "each" function. http://jsfiddle.net/hWwub/12/ – veritasetratio Jun 14 '13 at 00:34

1 Answers1

0

what selector do you use to find your svg elements. Seems like you can find only first one. You see it's incorrect to use same id for different elements anyway.

vchirkov
  • 1
  • 1