Make a div draggable

Make a div draggable

Here is a JS code that causes any div, on which the cursore moves, to change its color according to the css(see bellow the JS code).
Can someone modify this code so that the corresponding div becomes also graggable?
I mean that clicking on the div will make it graggable anywher on the vieport.
Thanks in advance
I. Sher

JS code:

prevElement = null;

document.addEventListener('mousemove',

function(e){

    varelem = e.target || e.srcElement;

    if (prevElement!= null) {prevElement.classList.remove("mouseOn");}

    elem.classList.add("mouseOn");

    prevElement = elem;

    },true);

CSS code:

.mouseOn{

  background-color: #bcd5eb !important;

  outline: 2px solid #5166bb !important;

}