Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Web Design, HTML And CSS Forums (http://www.go4expert.com/forums/web-design-forum/)
-   -   Refeering to new created SVG element using ECMAscipt (http://www.go4expert.com/forums/refeering-created-svg-element-using-t4247/)

rjblok 9May2007 18:00

Refeering to new created SVG element using ECMAscipt
 
Dear all,

I have used ECMAscript to add a SVG element to a webpage (I added a mouseover event to an existing svg element and the function it refers to creates a rectangle;
Code:

function bla (evt) {
      var svgNS = "http://www.w3.org/2000/svg";
      var vierkant = document.createElementNS(svgNS,"rect");
      rect1.setAttributeNS(null,"width",400);
      rect1.setAttributeNS(null,"height",80);
      rect1.setAttributeNS(null,"x",100);
      rect1.setAttributeNS(null,"y",100);
      rect1.setAttributeNS(null,"rx",20);
      rect1.setAttributeNS(null,"ry",20);
      rect1.setAttributeNS(null,"id","textblock");
      rect1.setAttributeNS(null,"visability","true");
      rect1.setAttributeNS(null,"stroke","black");             
      rect1.setAttributeNS(null,"fill","blue");
      rect1.setAttributeNS(null,"fill-opacity",0.2);
      document.getElementById("firstgroup").appendChild(rect1);
}

So far so good. But now I want to be able to click yet another element for this same rectangle to dissapear (be removed). Unfortunately, I did not find any possibilities to refer to this newly created rectangle. I added an id, but getElementByID does not seem to find it. I was hoping...

var test = svgDocument.getElementById("textblock");
test.parentNode.removeChild;

...would do the trick, but it doesn't.

Any ideas?

Robert


All times are GMT +5.5. The time now is 17:43.