shortening, I'm using (use) to replicate the square (path) the code is added to the DOM however, only 1px (debug chrome). Is not visible to the sixth block the User! thank you! code in: codepen
$(function() {
$('#svg').css('visibility', 'visible');
$('#svg use').css('fill', '#fff');
function addAnim() {
var $first = $('#svg use:not(.anim):first');
$first.attr('class', 'anim').css('fill', '#F15A29');
$first.animate({fill : '#F15A29'}, 500);
setTimeout(function() {
addAnim();
}, 100);
}
function replicar(){
var svg = document.getElementById('svg');
var elemento= document.createElementNS('ttp://www.w3/2000/svg', 'use');
elemento.setAttribute('xlink:href', '#shape');
elemento.setAttribute('y', '62');
elemento.setAttribute('x', '124');
elemento.setAttribute('fill', '#3D6EB5');
svg.appendChild(elemento);
addAnim();
replicar();
});
shortening, I'm using (use) to replicate the square (path) the code is added to the DOM however, only 1px (debug chrome). Is not visible to the sixth block the User! thank you! code in: codepen
$(function() {
$('#svg').css('visibility', 'visible');
$('#svg use').css('fill', '#fff');
function addAnim() {
var $first = $('#svg use:not(.anim):first');
$first.attr('class', 'anim').css('fill', '#F15A29');
$first.animate({fill : '#F15A29'}, 500);
setTimeout(function() {
addAnim();
}, 100);
}
function replicar(){
var svg = document.getElementById('svg');
var elemento= document.createElementNS('ttp://www.w3/2000/svg', 'use');
elemento.setAttribute('xlink:href', '#shape');
elemento.setAttribute('y', '62');
elemento.setAttribute('x', '124');
elemento.setAttribute('fill', '#3D6EB5');
svg.appendChild(elemento);
addAnim();
replicar();
});
Share
Improve this question
edited Jan 16, 2015 at 2:04
Jorg
7,2504 gold badges47 silver badges66 bronze badges
asked Jan 16, 2015 at 1:57
alexsouzadobrasilalexsouzadobrasil
234 bronze badges
1 Answer
Reset to default 11You are missing an 'h' in this line:
var elemento= document.createElementNS('http://www.w3/2000/svg', 'use');
Also, xlink attributes need to be added with setAttributeNS
.
elemento.setAttributeNS('http://www.w3/1999/xlink', 'xlink:href', '#shape');