Animations

API

Arrays

Async

Basics

Challenges

Classes

Console

Dates

Debugging

DOM Elements

DOM Methods

DOM Navigation

DOM Properties

Event Listeners

Flow Control

Forms

Functions

Global Functions

JSON

Keywords

Libraries (3rd party)

Math

Modules

Objects

Snippets

String

Types

Widgets

Window Object

JavaScript - OnMouseup / OnMousedown

The mousedown, mouseup and onclick events are all parts of a mouse-click. First when a mouse-button is clicked, the mousedown event is triggered, then, when the mouse-button is released, the mouseup event is triggered, finally, when the mouse-click is completed, the click event is triggered.

https://www.w3schools.com/js/js_htmldom_events.asp

Click Me

Syntax


// In HTML:
<element onmouseup="myScript"></element>

// In JavaScript:
object.onmouseup = function(){myScript};

// In JavaScript, using the addEventListener() method:
object.addEventListener("mouseup", myScript);



function mDown(obj)
{
    obj.style.backgroundColor = "#1ec5e5";
    obj.innerHTML = "Release Me";
}

function mUp(obj)
{
    obj.style.backgroundColor = "#D94A38";
    obj.innerHTML = "Thank You";
}