移動端以刻度或尺度滑動方式選擇年齡收入等

來源:互聯網
上載者:User

標籤:new   ges   ebe   end   .com   hang   實現   between   png   

實現方式用swiper.js

 

 

(以下以年齡為例)

1   <div class=‘testTwo‘>2       <p class=‘ageSel‘>您的年齡是<span class=‘scroAge‘> 20 </span>歲</p>3   </div>4     <div class="swiper-container">5        <span class="after"></span>6        <div class="swiper-wrapper">7        </div>8     </div>

 

 1     var ageLen=76 2       var strHtml=‘‘
     //動態產生0-76歲 3 for(var i=0;i<ageLen;i++){ 4 strHtml+="<div class=‘swiper-slide‘><span>"+i+"</span></div>" 5 } 6 $(".swiper-wrapper").append(strHtml) 7 8 var swiper = new Swiper(‘.swiper-container‘, { 9 initialSlide: 20, //初始年齡顯示在20歲10 pagination: ‘.swiper-pagination‘,11 slidesPerView: 6,12 centeredSlides: true,13 paginationClickable: true,14 spaceBetween: 0,15 onInit: function(swiper){16 var len=$(".swiper-slide").length17 var lenW=$(".swiper-slide").width()18 $(‘.swiper-wrapper‘).width(len*lenW);19 },20 onSlideChangeEnd: function(swiper){21 $(".scroAge").html(‘ ‘+$(‘.swiper-slide‘).eq(swiper.activeIndex).find(‘span‘).html()+‘ ‘)22 scroAge=$(‘.swiper-slide‘).eq(swiper.activeIndex).find(‘span‘).html()23 //console.log($(‘.swiper-slide‘).eq(swiper.activeIndex).html()) //切換結束時,告訴我現在是第幾個slide24 }25 });

 

移動端以刻度或尺度滑動方式選擇年齡收入等

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.