 <p>You can also use the <code>setAttribute()</code> function</p> <pre><code>function showElements(){ document.getElementsByClassName('blah')[0].setAttribute("data-symbol",document.getElementById('search').value); } </code></pre>