JSFiddle - React, Tailwind, and code Playground
HTML
<div id="TestID" class="div1">This is a test.</div>
JavaScript
var my_var;
//function 1
$(".div1").hover(function(){
my_var=$(this).attr('id'); //this doesn't work
});
//function 2
$(".div1").hover(function(){
//i want to make use of my_var here, but it is blank
alert(my_var);
});