J'essaie de soustraire 2 entiers les uns des autres, mais je continue à obtenir NaN
. Quelqu'un peut-il expliquer s'il vous plaît ce qui ne va pas avec mon code2 nombres soustraits l'un de l'autre font un NaN?
var moveit = null;
p = function (e){
if ((e.target.id == "windowContainer") || (e.target.id ==
"windowContainer2") || (e.target.id == "windowContainer3")){
console.log (e);
window.moveit = e.target;
window.onmousemove = p2;
var r = window.moveit.getBoundingClientRect();
var rl = r.left;
var rt = r.top;
window.onmouseup = function (e){
if (window.moveit == null) return;
window.moveit.onmousemove = window.moveit = null;
}
}
}
p2 = function (e, rt, epageY){
if (window.moveit == null) return;
var newY = rt - e.pageY;
console.log(isNaN(newY));
}
document.getElementById('windowContainer').onmousedown = p;
document.getElementById('windowContainer2').onmousedown = p;
document.getElementById('windowContainer3').onmousedown = p;
Pourquoi pensez-vous avoir deux entiers? 'rt' n'a aucune valeur. – SLaks