--- tags: jQuery --- ###### tags: `jQuery` # 表格根據響應式出現卷軸提示 ```jquery $(window).on('resize', function () { $('.table-responsive').each(function () { var tableWidth = $(this).find('table').width(), tableOuterWidth = $(this).width(); if (tableWidth > tableOuterWidth) { $(this).addClass('scroller'); } else { $(this).removeClass('scroller'); } }); }).trigger('resize'); ``` ```scss .b-product-detailed__wrap .scroller { background: url(../images/icons/scroll_hint.svg) top right no-repeat; background-size: 88px; padding-top: 35px; } ```