function createWarehouseSjdInfo(data){ $('#num').text(data.count) $('.tbodyMenu2').append( `${data.map((item)=>{ return `<tr> <td width="30%">${item.registration_no}</td> <td width="40%">${item.apl_name}</td> <td width="30%">${item.location}</td> </tr>` })}` ) //溢出滚动 var myScroll = function (options){ let defaults ={ speed:100, // 数值越大,速度越慢 rowHeight:24 // td的高 } let opts = $.extend({},defaults,options),intId = [] function actionAnimata(obj,he){ obj.find('.tbodyMenu2').animate({ marginTop:'-=1' },0,function (){ let ss = Math.abs(parseInt($(this).css('margin-top'))) if(ss >= he){ $(this).find('tr').slice(0,1).appendTo($(this)) $(this).css('margin-top','0') } }) } $('#tableMain').each(function (i){ let speed = opts['speed'],he = opts['rowHeight'],_this = $(this) goAnimate(i,_this,he,speed) _this.hover(function (){ clearInterval(intId[i]) },function (){ goAnimate(i,_this,he,speed) }) }) function goAnimate(index,obj,he,speed){ intId[index] = setInterval(()=>{ if(obj.find('.tbodyMenu2').height() <= obj.height()){ clearInterval(intId[index]) }else{ actionAnimata(obj,he) } },speed) } } myScroll({ speed:100, //数值越大,速度越慢 rowHeight:30 //td的高度 }) }
table 溢出滚动
最新推荐文章于 2024-12-16 15:27:04 发布