Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

HTML/SVG/JS use/def/onclick/id

Name: Anonymous 2011-04-13 14:59

hey /prog/,

I'm experimenting with html5 & friends, and I've run into a problem which you might be able to help me with...

I'm trying to use a <def> <circle> svg elements, placing it 4 times using the <use> tag with a unique id for each, then adding an onClick function so when I click each of the circles an alert tells me the unique id of each circle...

I've got everything fine, except instead of the unique id, I get told the id is "undefined"...

searching for "use" and "def" don't really return any helpful results in google/etc since it's too vague.

currently the relevant parts of my code look like:

for the circle definition:
<defs>
 <circle id="tBack" style="fill:daa;" cx="60px" cy="60px" r="50px"/>
</defs>

the <use> for circle instances:
<use id="circleAA" onclick="clicked(evt)" xlink:href="#tBack"/>
<use id="circleCA" onclick="clicked(evt)" xlink:href="#tBack" x="220" y="10"/>
etc...

and the onclick javascript:
function clicked(evt){
 alert(evt.target.id);
}

thanks for your time and any help given.

Name: VIPPER 2011-04-13 15:56

Here comes the /vip/ paladin.

Name: Anonymous 2011-04-13 17:31

Take it from an EXPERT HTML /PROG/RAMMER , <p> is much better!

Don't change these.
Name: Email:
Entire Thread Thread List