I have a div with a number, which changes dynamically in php. The number comes from the slide number in the Supersized plugin. I have tried my best to figure out how to change the plugin, so I could fix it with php, but without any luck.
I would like to "force" this number to always have a 0 in front of it, if it is below 10. So if the number is 5, it should be 05.
I found a solution with jQuery, but it is only working until the next slide loads and the number changes, and then the next number has no zero in front of it. This is the script:
$(".number").text(function(i, val){
return $.trim(val).length === 1 ? '0' + val : val;
});
Is there a way to make jQuery keep checking the number, and adding a zero every time the number is below 10? Or some other solution?
Hope someone can help :)