The newest: I find the question is the opera! It can work in the firefox!But I need opera to use it,does it have any solution? PS:waiting the jquery or opera's uncoming version?
I want to ask why $("g[id^=trans]") cannot work,but the $("g") can?How to fix it? The load method of jQuery SVG plugin must work under the server such as Apache.(I don't know why?But it will not work if not under the Apache) The javascript
<html><head><script type="text/javascript" src="http://code.jquery.com/jquery.js">
</script><script type="text/javascript" src="http://keith-wood.name/js/jquery.svg.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#svgload").svg();
var svg = $('#svgload').svg('get');
$('#loadsvg').click(function() {
svg.load('red.svg',{onLoad:loadDone});
});function loadDone(svg, error) {
svg.text(10, 20, error || 'Loaded into ' + this.id);
}
$('#transform').click(function(){
//alert($("g").attr("transform"));
alert("before="+svg.toSVG());
$("g[id^=trans]").attr("transform","translate(20,5)");//this cannot work!How to fix it?
//$("g").attr("transform","translate(20,5)");//this can work!
alert("after="+svg.toSVG());
});
});</script></head><body>
<div id="svgload" width="200px" height="200px" >
</div>
<button id="loadsvg" type="button">loadsvg</button>
<button id="transform" type="button">transform</button></body></html>`
The SVG:
<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
<g id="trans001">
<rect x="35" y="50" width="20" height="20" fill="#F3D70A" stroke-width="4"/>
<line x1="20" y1="40" x2="80" y2="40" stroke-width="5"/>
<circle cx="20" cy="60" r="10" fill="red" stroke="blue" stroke-width="5"/></g>
<g id="trans002"><rect width="35" height="20" x="20" y="90" fill="blue">
</rect></g>
</svg>