I have two buttons to move a box up or down with JQuery being used to get the CSS 'top' value which is being either added to or subtracted from. When subtracted from, it works as expected but when added to it does not.
It seems to be a case of the addition sign being confused for concatenation instead. Some brackets were then put around the numbers being added but this made no difference.
The working code, ie, when subtraction occurs is shown below:
$('#dir_panel_form').css({
'top': $('#dir_panel_form').css('top').substring(0, $('#dir_panel_form').css('top').length - 2) - 30 + 'px'
});
The non-working code, ie, when addition occurs is shown below with the extra set of brackets bolded:
$('#dir_panel_form').css({
'top': ($('#dir_panel_form').css('top').substring(0, $('#dir_panel_form').css('top').length - 2) + 30) + 'px'
});
The snippet with the extra brackets (again bolded) is also shown below:
($('#dir_panel_form').css('top').substring(0, $('#dir_panel_form').css('top').length - 2) + 30)
Can anyone sought this out?