<input class="qwerty" type="text" data-id="bla-bla-bla" /> <script> var inp = document.querySelector('.qwerty'); inp.id = inp.getAttribute('data-id'); </script>