-2

I need display different content when screen width less than 768px and normal.

I tried something like this, but it don't work:

<script>
if(screen.width <= '768') 
{ 
document.write( '<table class="small-tbl"> ... </table>' ); 
} 
else  
{ 
document.write( '<table class="beeg-tbl"> ... </table>' ); 
} 
</script>
Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120

1 Answers1

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>