Cevizli Cevizli - 1 month ago 13
jQuery Question

Jquery Update Function like Unity3D

My variable nim is not updating the seconds call

$( "#upbutton" ).click(function() {
var nim = $("a").css("margin-top").replace("px", "");
nim+=70;
$("#moved").css('margin-top',nim+'px');
});


nim = 70 and does not change.

Answer
var nim = $("a").css("margin-top").replace("px", "");

$( "#upbutton" ).click(function() {
    nim += 70;
    $("#moved").css( 'margin-top', nim + 'px' );
});