JSFiddle - React, Tailwind, and code Playground

HTML

<div class="myiv" style="height:20px;background-color:#BBB"></div>
<div id="box" style="position:absolute;height:10px;width:10px;background-color:#000">

</div>

JavaScript

var x = 100; // number of milliseconds
var intervalId;
$('.myiv').hover(
    function () {
        // the element is hovered over... do stuff
        intervalId = window.setInterval(someFunction, x);
    }, 
    function () {
        // the element is no longer hovered... do stuff
        window.clearInterval(intervalId);
    }
);

var someFunction = function () {
    $('#box').css('left', $('#box').offset().left + 10 + 'px');
};