document.write或类似的东西如何在需要时显示包含内容的表格?

问题描述 投票:-2回答:1

当屏幕宽度小于768px且正常时,我需要显示不同的内容。

我试过这样的东西,但它不起作用:

<script>
if(screen.width <= '768') 
{ 
document.write( '<table class="small-tbl"> ... </table>' ); 
} 
else  
{ 
document.write( '<table class="beeg-tbl"> ... </table>' ); 
} 
</script>
javascript html-table width condition
1个回答
0
投票
     <script>
    $(document).ready(function(){
     $( ".cart-tbl-small" ).hide();
     $( ".cart-tbl-beeg" ).hide();
     });
         </script>
             <script>
                var windowSize = $(window).width();
     $(document).ready(function(){
     if(windowSize <= '768') 
{ 
$( ".cart-tbl-small" ).show();
} 
else  
{ 
$( ".cart-tbl-beeg" ).show();
} 
     });
     </script>
© www.soinside.com 2019 - 2024. All rights reserved.