亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么t會出現4 和-1

為什么t會出現4 和-1

婷婷同學_ 2018-10-16 17:14:28
var t = 0;var _id;function categoryCarousel (t){     $(".title li").eq(t).stop().addClass('cur').siblings().removeClass('cur'),     _id = $(".title li").eq(t).attr('id');    var showUl = $("#" + _id + "list ");     showUl.stop().show().siblings("ul").hide();     $("#" + _id + "list .line").show(); }$(document).on('click', '#next', function () {    if (t > 3 ) {         t = -1;     };     categoryCarousel (++t);    console.log(t) }); $(document).on('click', '#pre', function () {    if (t < 0) {         t = 3;     };     categoryCarousel (--t)    console.log(t) });
查看完整描述

1 回答

?
慕田峪7331174

TA貢獻1828條經驗 獲得超13個贊

應該是t=3t=0的時候不符合if判斷,然后執行了++t(t=4)--t(t=-1)導致的。
你看根據你的業務邏輯改為if(t>=3);if(t<=0);還是額外加一些語句比較好。


查看完整回答
反對 回復 2018-11-10
  • 1 回答
  • 0 關注
  • 491 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號