Js calls the same method twice and executes only the second method.

in the same js file, there are two written methods: aPermib. It can be run when the c method is called, but only the second d method is executed if both methods c _ ab d call the above method at the same time. What to do, whether to make a packet into a packet or put it in another js file.

these two are operation methods

function a(first) { //
    first.onmousedown = function (e) {      //onclickmouseover,onmousedown
        e.preventDefault && e.preventDefault(); //  !!!
        var x = e.clientX - first.offsetLeft;
        var y = e.clientY - first.offsetTop;
        document.onmousemove = function (e) {
            first.style.left = e.clientX - x + "px";
            first.style.top = e.clientY - y + "px";
        };
        document.onmouseup = function () {
            document.onmousemove = null;
            document.onmouseup=null;
        }
    }
};

//Collision detection,,firstsecondmethod;
function  b(first,second,method) {
    //
    /*    var first=document.getElementById("-sharp");//
        var second=document.getElementById("-sharp");//*/
    first.onmousemove=function () {  //first
        var t1 = first.offsetTop,
            l1 = first.offsetLeft,
            r1 = first.offsetLeft + first.offsetWidth,
            b1 = first.offsetTop + first.offsetHeight;
        var t2 = second.offsetTop,
            l2 = second.offsetLeft,
            r2 = second.offsetLeft + second.offsetWidth,
            b2 = second.offsetTop + second.offsetHeight;
        var noConflict=b1<t2 || l1>r2 || t1>b2 || r1<l2;// 
        if(!noConflict){  //;
            // return true;
            method.f();  //json;
            // method();  //;
        }
    }
}

two calls

function c() {
    var method={   //json
        name:"method",
        f:function () { //firstsecond;
          //
    }
    move(first);
    CD(first,second,method);
}

function d(){
    var method={
        name:"method",
        f:function () {
               //
    }
        }
       move(first);
       CD(first,second,method);

}
cdfirst,second,method
Mar.01,2021

binds an event to the same object by assignment, and the event that is bound later replaces the previous one. If you need to keep both, you can use addEventListener


to adjust according to the answer of the border city god, and add if judgment to sort the order of events.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3cbff-408c6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3cbff-408c6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?