Javascript examples for DOM HTML Element:Button
Set button CSS style position to fixed
<html> <head></head> <body> <script type="text/javascript"> counter = 1;//from w ww .j a va 2s .c om document.onclick = function(e) { var button = document.createElement('button'); button.style.position = 'fixed'; button.style.left = e.pageX + 'px'; button.style.top = e.pageY + 'px'; button.innerHTML = counter; counter++; document.body.appendChild(button); setTimeout(function() { document.body.removeChild(button); }, 1000); }; </script> </body> </html>