after
svg {
fill: #000000;
transition: fill 0.5s ease;
-webkit-transition: fill 0.5s ease;
}
</style>
<svg height="400" width="400">
<text font-family="Sans-serif" font-size="54" font-weight="bold" id="svg_2" x="41" y="220">barioléatoire</text>
</svg>
<script>
var select = function(s) {
return document.querySelector(s);
};
var svgItem = select('svg');
var chars = '0123456789ABCDEF'.split('');
var randomColor = function () {
var color = '#';
for (var i = 0; i < 6; i++)
color += chars[Math.floor(Math.random() * 16)];
return color;
};
setInterval(function () {
svgItem.style.fill = randomColor();
}, 500);
</script>