JSFiddle - React, Tailwind, and code Playground

by alx000

HTML

<div id="body">
<p id="mypara">
Press the mouse left key above the gray div and move the cursor above this text.
</p>
</div>

CSS

#mypara {
border: 1px solid #000;
padding:20px;
}
#body {
padding: 20px;
    background: #ccc;
}

JavaScript

window.addEvent('domready', function() {
    var over = false;
    var pressed = false;
    $('body').addEvent('mousedown', function(e1) {
        pressed = true;
        if (over) {
            alert('pressed+over');
        }
    });
    $('body').addEvent('mouseup', function(e1) {
        pressed = false;
    });
    $('body').addEvent('mouseleave', function(e1) {
        pressed = false;
    });
    $('mypara').addEvent('mouseenter', function(e) {
        over = true;
        if (pressed) {
            alert('pressed+over');
        }
    });
    $('mypara').addEvent('mouseleave', function(e) {
        over = false;
        if (pressed) {
            alert('pressed+over');
        }
    });
});