<script> var elements = document.querySelectorAll('figure'); for (var i = 0; i < elements.length; i++) { var lang = elements[i].getAttribute("class"); if (lang != null ) { lang = lang.substr(10); } elements[i].setAttribute("data-language", lang); } </script>