I am trying to wrap a DOM
element to new element one I create. But not works.
function moveToLink(){
var button = document.getElementById('button');
var link = document.createElement('a');
link.setAttribute('href', '#');
link.appendChild( button); // need wrap
}
moveToLink();
a{
border:2px solid gray;
display:block;
}
<input type="button" id="button" value="try me" onclick="moveToLink()">