[Solved] Trying to make box that i can move if i click on it [closed]


Your main problems are :

Missing $ in :

var cx=$('#box').css("left");
       ^ // missing
var cy=$('#box').css("top");
       ^

Setting local var for ch in first click handler. This means the higher level ch is never defined and never changes

 $('#box').on("click",function(){
    clicked=clicked+1;
    ch=clicked%2; // remove `var`
    alert('ch'+ch);
  });

The box now moves although not smoothly and I don’t know what your expectations are.

3

solved Trying to make box that i can move if i click on it [closed]