tags:

views:

12

answers:

0

Hi i want to delete the svg element using in javascript ...i didnt made the external file of svg i have done all my svg creation in html file (dynamic creation) ..but i am unale to remove the svg element frm it...i m not able to access the parent node in it...

heree is the code

<div align="center" id="dd" style="border-color: red;border-style: dashed;position: fixed;width: 800px;height: 600px;right: 250px;bottom: 130px" title="SVG Graphics Zone"></div>
<div id="box" style="position: fixed;width: 100px;height: 100px;right: 250px;bottom: 130px;background-color: yellow" title="SVG Box">
    <script type="text/javascript">

        var lay_B=new Array();


        var container = document.getElementById("dd");
        var mySvg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
        mySvg.setAttribute("version", "1.2");
        mySvg.setAttribute("baseProfile", "tiny");
        mySvg.setAttribute("width", "800px")
        mySvg.setAttribute("height", "700px")
        mySvg.setAttribute("x", "0")
        mySvg.setAttribute("y", "0")
        container.appendChild(mySvg);

function circle() {

        var circle=document.createElementNS("http://www.w3.org/2000/svg", "circle")
            circle.setAttribute("id", "btn_circle")
            circle.setAttribute("cx", "630")
            circle.setAttribute("cy", "645")
            circle.setAttribute("r", "20")
            circle.setAttribute("stroke-width","2" )
            circle.setAttribute("stroke","#000000")
            circle.setAttribute("fill","purple")
            mySvg.appendChild(circle);


    //alert(btn_circle)

//*********** lay_B.push();

        }
        function cube()
        {


           var rec = document.createElementNS("http://www.w3.org/2000/svg", "rect");
            rec.setAttribute("id", "btn_rect");
            rec.setAttribute("fill","yellowgreen")
            rec.setAttribute("stroke","black")
            rec.setAttribute( "x","605px")
            rec.setAttribute( "y","620px")
            rec.setAttribute( "width","50px")
            rec.setAttribute( "height","50px")
            rec.setAttribute( "rx","10px")
            rec.setAttribute( "ry","10px")

   mySvg.appendChild(rec);
   //var cc=c.getElementById('btn_rect');


            //***********************
            lay_B.push();

        }

now i want to delete the circle..but i am not able to do it...please help me out...Thnaks in advance...