在jQuery中SVG插件(http://plugins.jquery.com/project/svg)與SVG工作執行從DIV元素開始和創建div中新的SVG對象:SVG通過jQuery.svg
Attach an SVG canvas to a with the following:
$(selector).svg();
是否有可能與連接jquery到現有的svg對象?如果「是」如何做到這一點?
編輯: 司機小費
<body onload="alert('loaded');testSvg();">
<div id="div3" style="border: solid 1px black; width:200px; height:100px">
<svg id="svg3" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></svg>
</div>
<script type="text/javascript">
function testSvg() {
var svgRootElement = $("#svg3").get();
var svgWrapper = new $.svg._wrapperClass(svgRootElement);
svgWrapper.circle(30, 25, 50, { fill: 'red' });
}
導致錯誤:
'TypeError: Unable to get value of the property 'createElementNS': object is null or undefined' error...
爲什麼呢?
我建議你出打破編輯成新問題。我對如何回答這個問題有了一個想法,但是在這裏回答它會太混亂。 – jbeard4 2011-05-15 21:14:33
完成:http://stackoverflow.com/questions/6033939/how-to-create-jquery-wrapper-on-existing-svg-object – Budda 2011-05-17 16:19:15