JQuery object and DOM - how do I use javascript to detect the underlying element and add a string to it


I'm trying to do a generic function that adds all the different object elements needed for SVGWeb to work properly. That's the easy part but how can I use javascript to detect underlying element and append string to that.

I would like to do this type of markup:


The point is that I don't want to specify the underlying element every time I want to put graphics on the page. It would make updating very annoying when you want to move graphics around and they are tied to specific element ids. My goal is to be able to use this like I could use img tag.

I have jQuery on the page so that could be used as well.

edit To clarify the question is that how do I pass the underlying element to javascript and append object string that svg() returns to the DOM? I tried $(this) but doesn't work.

Here's an example of what i think you're trying to do: svg example

Create your placeholder divs with appropriate classes and then use jquery to fill them in with the correct svg.