<svg width="6cm" height="5cm" viewBox="0 0 600 500" version="1.1"> <desc>Example script01 - invoke an ECMAScript function from an onclick event </desc> <script type="text/ecmascript"> function circle_click(evt) { var circle = evt.target; var currentRadius = circle.getAttribute("r"); if (currentRadius == 100) circle.setAttribute("r", currentRadius*2); else circle.setAttribute("r", currentRadius*0.5); } </script> <rect x="1" y="1" width="598" height="498" fill="none" stroke="blue"/> <circle onclick="circle_click(evt)" cx="300" cy="225" r="100" fill="red"/> <text x="300" y="480" font-family="Verdana" font-size="35" text-anchor="middle"> Click on circle to change its size </text> </svg> |
Original SVG source |