spin jquery ui spinner from array values

微笑、不失礼 提交于 2019-12-11 02:03:30

问题


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.


回答1:


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()]);
    }
 });

You can see how I did it in here



来源:https://stackoverflow.com/questions/25981586/spin-jquery-ui-spinner-from-array-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!