JSFiddle - React, Tailwind, and code Playground

HTML

<input type="number">
<div id="result"></div>
<button>Get result2</button>
<div id="result2"></div>

JavaScript

(function(){
  var inputValue;
  $('input').on('change', function() {
    inputValue = $(this).val();
    $('#result').html(inputValue);
  });

  $('input').click('button', function() {
    $('#result2').html(inputValue);
  });
})();