trying to create a terminal using jquery.terminal

290 Views Asked by At

Hi I am trying to create a jquery.terminal. I tried to follow this article, here it uses the body tag, I wish to use only a div for the terminal area not the whole body. Tried accessing the <div id="myterm"></div> like

<script>
  $('#myterm').terminal({
    hello: function (name) {
      this.echo('Hello, ' + name + '. Welcome to MyTerm');
    }
  },
  {
    greetings: 'Checkout help !'
  });
</script>

But didn't work !

1

There are 1 best solutions below

2
IT goldman On

Yes it does work. Try hello world on the prompt

$('#myterm').terminal({
    hello: function (name) {
      this.echo('Hello, ' + name + '. Welcome to MyTerm');
    }
  },
  {
    greetings: 'Checkout help !'
  });
#myterm {
  height: 300px;
  border: 1pxs solid red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.34.0/js/jquery.terminal.min.js" integrity="sha512-lfkU/Qku0yOVZEYANlw2mOv7fpHFdS1E62UT7vJ55k22OB+xgRNNa6Cdor4Lugl4jhDjX29lJAG12X/OHFe8JQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.34.0/css/jquery.terminal.css" integrity="sha512-lT1/Sb6Bu4LaJJoTsxNZnlvt7pjuntBoSqSMJY7MxG5Yl1XgxsXA6jcJinPU0lx5eEsnudBE1ubzHSYR/W8xTw==" crossorigin="anonymous" referrerpolicy="no-referrer" />

<div id="myterm"></div>