0

I tried to make my images smaller when screen width is less than 1024 but it's not working. Can someone help?

<script type="text/javascript">
    if( $(window).width() < 1024)
        {
           $(".imagelist").animate({ width: '2750px',height:'540px'})1000
           $("img").animate({ width: '250px',height:'250px'})1000
        }  
});
</script>  
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
Raphael Bergeron
  • 45
  • 1
  • 1
  • 8

2 Answers2

2

Like Mohamed-Yousef said, you are missing a comma. But there are also some other syntax issues. Try:

<script type="text/javascript">
    if( $(window).width() < 1024)
    {
        $(".imagelist").animate({width:'2750px',height:'540px'}, 1000);
        $("img").animate({ width:'250px',height:'250px'}, 1000);
    }
</script>
tgallacher
  • 1,594
  • 1
  • 10
  • 7
0

about })1000 it should be },1000)

<script type="text/javascript">
 $(document).ready(function(){
    if( $(window).width() < 1024)
        {
           $(".imagelist").animate({ width: '2750px',height:'540px'},1000);
           $("img").animate({ width: '250px',height:'250px'},1000);
        }  
});
</script>  
Mohamed-Yousef
  • 23,946
  • 3
  • 19
  • 28
  • @RaphaelBergeron This is your ticket - notice he added semi-colons to the end of each statement too. To get this to work if your window is resized, you could add a resize listener too `$(window).on('resize', function(){ /* code here */});`. If you do that, you may want to consider stopping the animation before processing the reverse animation (which you would add if the window is resized to larger than 1024) `$('.imagelist').stop().animate({/*params*/});`. –  May 10 '16 at 22:03