JSFiddle - React, Tailwind, and code Playground

HTML

<input value="document.body.style.backgroundColor = 'white'">
<button onclick="pew(this)">Push me</button><br>

<input value="document.body.style.backgroundColor = 'green'">
<button onclick="pew(this)">Push me</button><br>

<input value="document.body.style.backgroundColor = 'yellow'; alert('yellow!')">
<button onclick="pew(this)">Push me</button><br>

CSS

body {
	width:100%;
	height:600px;
	background-color:red;
}
input {
  width: calc(100% - 100px);
}

JavaScript

function pew(btn) {
  var text = btn.previousElementSibling.value;
  var script = document.createElement("script");
  script.innerHTML = text;
  document.head.appendChild(script);
}