Damiano Barbati
Damiano Barbati

Reputation: 3496

Jquery selector with svg

I'm manipulating an svg and I'd like to access the elements by jquery and his selectors but they doesn't seem to work: all the other functions like getJSON and .ajax work without any problem.

The browser load a file.svg, not an html page with svg contents in it. How do I change the value of this text element for example? (this node is a root child)

<text id="green_nick"  class="nickname" x="1200" y="279" onclick="takeSeat(evt)">a234567890a2345</text>

// this doesnt work
$.("#green_nick").val("changeit!")

Upvotes: 3

Views: 9981

Answers (2)

Chasbeen
Chasbeen

Reputation: 1436

jQuery SVg is the solution if you have a little time for a short learning curve that delivers a lot Convert your SVG into Kieth's jQuery SVG. You cam add a jQuery SVG Lin from his package which allows you to control the Dom Also view the "matrix" chart on the converter

http://irunmywebsite.com/raphael/SVGTOHTML_LIVE.php

Choose the 3rd option on the dropdown as the first 2 are for another SVG library

You will find the Matrix info that complements the above information to control the Dom

Upvotes: 1

ldiqual
ldiqual

Reputation: 15365

As SVG uses non-standard elements, it can't be manipulated like DOM elements. You should look at jQuery SVG to manipulate SVG Elements.

Upvotes: 1

Related Questions