有人尝试过使用使用数组作为源数据的 jQUery UI Spinner 吗?基本上我真正想要实现的是我有一个数据列表(在带有字符串值的数组中),我希望我的旋转器仅使用这些数组值旋转。希望有人能告诉我该怎么做。
最佳答案
好吧,我想我要回答我自己的问题,只是为了其他可能有同样问题的人。
var dlist = ['banana','papaya','apple']
$( ".spinner" ).spinner({
min: 0,
max: 2,
create: function(){
$(this).parent().append('<input class="spinner-text" value="'+dlist[$(this).val()]+'">');
},
stop: function(event,ui) {
$(this).siblings('.spinner-text').val(dlist[$(this).val()]);
}
});
你可以在 here 中看到我是如何做到的
关于jquery - 从数组值旋转 jquery ui spinner,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25981586/