0
javascriptを使用して動的に作成されたパスを埋める必要があります。私はそれのためのグラデーションを作成し、私のパスを埋めるためにそれを使用したが、何も起こらなかった。私のコードに何が問題なのですか?LinearGradient for path SVG
$('svg').prepend('<defs id="gradient"></defs>');
$('#gradient').append('<linearGradient id="yellow" x1="0%" y1="0%" x2="100%" y2="0%"> </linearGradient>');
$('#yellow').append('<stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1" /> <stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" />');
$('g:nth-child(2n+1) path').attr('fill','url(#gradient)');`