You got getElementsByClassName wrong, and you need to iterate over the set of elements and change stellar.ration to stellarRatio .
var eles = document.getElementsByClassName('text'); for (var x = 0; x < eles.length; x++){ eles[x].dataset.stellarRatio = "2"; }
source share