JSFiddle - React, Tailwind, and code Playground

by namnium1125

HTML

<input type="text" /> <button>hogeの中身</button>
<div></div>

JavaScript

var hoge = '';
var print;

$(function(){
  print = function(text){
    $('div').html($('div').html() + text + '<br />');
  };
});

$(function(){
  $('input').on('change',function(e){
    hoge = e.target.value;
    print('ここじゃない!の場所 : ' + hoge);
  })
  print('ここのグローバル変数を加算していきたい!の場所 : ' + hoge);
});

$(function(){
  $('button').click(function(){
    print('ちゃんとグローバルに保存されている : ' + hoge);
  });
});