I already created an SVG, Now my problem is to add a few codes dynamically in between two elements.
How can I achieve it? even JS or jquery no problem!
<svg width="500" height="500">
<circle id="circle1" class="sid" cx="50" cy="50" r="20" fill="red"/>
<circle id="circle2" class="sid" cx="150" cy="50" r="20" fill="green"/>
<circle id="circle4" cx="350" class="sid" cy="50" r="20" fill="yellow"/>
</svg>
$(document).ready(function() {
$(".sid").mouseenter(function() {
alert("I'm here");
$('#circle2').append('<circle id="circle3" cx="250" class="sid" cy="50" r="20" fill="blue"/>');
});
$(".sid").mouseleave(function() {
// action
});
});
is it possible instead of creating SVG adding few codes inside of elements between?
Expecting output like.
<svg width="500" height="500">
<circle id="circle1" class="sid" cx="50" cy="50" r="20" fill="red"/>
<circle id="circle2" class="sid" cx="150" cy="50" r="20" fill="green"/>
<circle id="circle3" cx="250" class="sid" cy="50" r="20" fill="blue"/>
<circle id="circle4" cx="350" class="sid" cy="50" r="20" fill="yellow"/>
</svg>