一段有用的JS

(function() {
  const container = document.createElement('div');
  const console = document.createElement('pre');
  const input = document.createElement('textarea');
  const exec = document.createElement('button');

  const log = (text) => {
    console.appendChild(document.createTextNode(text));
  };

  const clear = () => {
    console.textContent = '';
  };

  input.cols = 60;
  input.rows = 8;
  exec.textContent = 'exec';
  exec.type = 'button';
  exec.onclick = () => {
    eval(input.value);
  };
  container.appendChild(input);
  container.appendChild(exec);
  container.appendChild(console);
  document.body.insertAdjacentElement('afterbegin', container);
})();

  点击button执行textarea框内的js

上一篇:pytest之配置可选的项目系统URL(pytest-base-url)


下一篇:pytest测试实战 (如何使用pycharm 上传代码到远程仓库)