当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - How do I get a jQuery Mobile slider for hexadecimal numbers?

问题描述:

I am trying to alter the behavior of the normal jQuery Mobile slider widget to display hexadecimal numbers. However, I don't get it to work.

The slider's slidestart and slidestop events aren't appropriate, since they only trigger at the start and stop of the interaction respectively.

So, I tried to bind a change handler to the input element of the slider instead.

$("input", slider).on("change", function() {

// change the value of the input to hexadecimal...

});

Doesn't work either. Nothing happens. Is there a way to achieve this?

网友答案:

Gajotres pointed me to a bug in my conversion code. Binding a change handler to the input element of the slider was the right approach, though.

So for the sake of completeness (and others with the same problem) here is my final solution.

$("input", slider).on("change", function() {
    var number = parseInt(this.value);
    $(this).val(number.toString(16));
});
分享给朋友:
您可能感兴趣的文章:
随机阅读: