/* 
  using the id of the newly created button 
  to style it
*/
#button-1 {
  display: block;
  padding: 5px 15px;
  border: 1px solid red;
  border-radius: 5px;
  text-transform: uppercase;
}
View Compiled
const body = document.body;
const textArea = document.createElement('textarea');
const button = document.createElement('button');
button.textContent = 'Click Me';
button.id = 'button-1' // add an id to it

body.append(textArea);
body.append(button)

// often referred to as a 'handler'
function clickHandler() {
  console.log('abc');
}

button.addEventListener('click', clickHandler);

// get newly created button from the DOM
console.log(document.getElementById('button-1'))
// <button id="button-1">Click Me</button>
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.