从数组值旋转jQuery UI Spinner [英] spin jquery ui spinner from array values
本文介绍了从数组值旋转jQuery UI Spinner的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有人尝试使用将数组作为其源数据的jQUery UI Spinner?基本上,我真正想要实现的是我有一个数据列表(带有字符串值的数组),我希望微调器仅旋转那些数组值.希望有人可以告诉我该怎么做.
Have anyone tried to use jQUery UI Spinner that uses array as its source data? Basically what I really want to achieve is I have a list of data (in array with string values), I want my spinner to just spin only with those array values. Hope someone could show me how to do it.
推荐答案
好吧,我想我要回答我自己的问题,只是为了其他可能遇到相同问题的人.
Ok, I think I'm going to answer my own question, just for the sake for other people who might have the same issue.
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()]);
}
});
您可以在此处
这篇关于从数组值旋转jQuery UI Spinner的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文