jQuery图像根据分辨率调整大小

时间:2014-08-21 13:57:32

标签: javascript jquery html

我有以下jQuery snipper,但似乎没有工作。该脚本应该使用' img'来调整所有图像的大小(带动画)。只要窗口的宽度低于960px,就会出现id。这是jQuery代码:

<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $(window).resize(function(){
    if ($(window).width() < 960)
    {               
        $('.img').animate({ width: '100px' });
    }
    else
    {
        $('.img').animate({ width: '200px' });
    }
     });
});
</script>

图片的HTML代码:

<figure><a href="/index.php?ll={LANG}&pag=test"><img src="img/test/1.jpg" class="img"><figcaption>{IMG1_FOOTER}</figcaption></a></figure>

知道为什么这不能按预期工作吗?

提前致意并表示感谢!

0 个答案:

没有答案
相关问题