<div class="q"></div> <script> document.querySelector(".q").insertAdjacentHTML('beforeend', "<input type='button' onClick='qwe()' value='Ok'>"); </script>