在不去掉前导零的情况下增加一个数字 jquery

Bro*_*val 2 html javascript jquery

我从数据库中获取一个值,我将它作为一个数字重复使用,这个数字有前导零,并且它仅限于 4 位数字,意思是说格式是0001or 0010or 0100or1000当我加 1 时,我从零开始计数例如,我添加的方式前导零消失了

var databasevalue = 0000;
var incrementvalue = parseInt(databasevalue) + parseInt(1); 
Run Code Online (Sandbox Code Playgroud)

fca*_*ran 5

// I suppose databasevalue is a string
var databasevalue = "0125"; 

// coerce the previous variable as a number and add 1
var incrementvalue = (+databasevalue) + 1;

// insert leading zeroes with a negative slice
incrementvalue = ("0000" + incrementvalue).slice(-4); // -> result: "0126"
Run Code Online (Sandbox Code Playgroud)