Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用jquery放大图像_Jquery - Fatal编程技术网

用jquery放大图像

用jquery放大图像,jquery,Jquery,我真的不知道我怎样才能对这页上的图片产生同样的效果。正如您将看到的,有一篇文章的图像很小,但当用户单击图像时,它会放大整个宽度。有人知道如何复制这个吗 提前谢谢!一旦我收到答复,我将要求。删除它,因为我知道它不显示任何代码或任何东西 直接从该页面的源代码链接: $('a.resizeimg').click(function(){ if (!resized) { $(this).find("figure").hide();

我真的不知道我怎样才能对这页上的图片产生同样的效果。正如您将看到的,有一篇文章的图像很小,但当用户单击图像时,它会放大整个宽度。有人知道如何复制这个吗

提前谢谢!一旦我收到答复,我将要求。删除它,因为我知道它不显示任何代码或任何东西


直接从该页面的源代码链接:

$('a.resizeimg').click(function(){
                if (!resized) {
                    $(this).find("figure").hide();
                    $(this).parent().animate({'width':632,'height':470}, 300);
                    $(this).find("img").animate({'width':632,'height':470}, 300, function(){
                        $('a.resizeimg').find("figure").show();
                        var header = parseInt($("header").css("height"));
                        if(header == 92) {
                            clanakHeight = parseInt($('article.clanak').height())+69-parseInt($(".additional").height());
                        }
                        else if(header == 51) {
                            clanakHeight = parseInt($('article.clanak').height())+181-parseInt($(".additional").height());
                        }
                    });
                    $(this).next("p.opis").animate({'width':622}, 300);
                    $(this).find("figure").css({'width':632,'height':470});
                    resized = true;
                }
                else if (resized) {
                    $(this).find("figure").hide();
                    $(this).parent().animate({'width':316,'height':235}, 300);
                    $(this).find("img").animate({'width':316,'height':235}, 300,function(){
                        $('a.resizeimg').find("figure").show();
                        var header = parseInt($("header").css("height"));
                        if(header == 92) {
                            clanakHeight = parseInt($('article.clanak').height())+69-parseInt($(".additional").height());
                        }
                        else if(header == 51) {
                            clanakHeight = parseInt($('article.clanak').height())+181-parseInt($(".additional").height());
                        }
                    });
                    $(this).find("figure").css({'width':316,'height':235});
                    $(this).next("p.opis").animate({'width':306}, 300);
                    resized = false;    
                }

                return false;
            });
当然可以:

HTML


看看这个

嗨,Joakim,你知道我如何简化它吗?请检查下面我的新答案!非常感谢你!我真的很感激,没问题!很乐意帮忙。
<img id="myImage" src="http://www.manifestic.com/images/smpanda.jpg">
var resized;
$('#myImage').click(function(){
    if (!resized) {
        $(this).animate({'width':632,'height':470}, 300);
        resized = true;    
    }
    else if (resized) {
        $(this).animate({'width':283,'height':360}, 300);
        resized = false;    
    }

    return false;
});