infatti
infatti

Reputation: 37

jQuery UI Slider ui.value get last digit

How do I get ONLY the last digit from the ui.value of a slider that is two digits long (XX).

I tried this but it does not seem to be acceptable?

var $lastNumber = ui.value.length-1;

Upvotes: 0

Views: 225

Answers (2)

Theraot
Theraot

Reputation: 40285

How about:

var $lastNumber = ui.value % 10;

Upvotes: 3

Ayman Safadi
Ayman Safadi

Reputation: 11552

Try:

var sliderVal   = ui.value;
var $lastNumber = sliderVal.toString().charAt(sliderVal.length-1)

Upvotes: 0

Related Questions