can someone help me debug this please??? i'm really don't know whats wrong with my code...
i'm trying to add number value to another number value.... but it does not work as i expected...instead it just add the number as a string.
Here is my demo: (already solved)
and here is the js code:
$(document).ready(function(){
$("#map").click(function(e){
var x = parseInt((e.pageX - this.offsetLeft)) - parseInt("140");
var y = parseInt((e.pageY - this.offsetTop)) - parseInt("140");
var coor = $("#map").css("background-position").split(" ");
var cx = parseInt(coor[0].replace("px",""));
var cy = parseInt(coor[1].replace("px",""));
$("#map").stop().animate({"backgroundPosition": x+cx+" "+y+cy},"slow");
alert("X:"+x+", CX: "+cx+"\n Y:"+y+", CY:"+cy+"\n Background-pos:"+$("#map").css("background-position"));
});
});
please tell me what's wrong with it...