How to zoom div content using jquery?

前端 未结 4 1472
广开言路
广开言路 2020-12-07 16:09

I have a parent

. Inside that I place some text and images. Now I need to zoom to a particular portion of that parent
. Is i
4条回答
  •  醉梦人生
    2020-12-07 16:26

    If you want that image to be zoomed on mouse hover :

    $(document).ready( function() {
    $('#div img').hover(
        function() {
            $(this).animate({ 'zoom': 1.2 }, 400);
        },
        function() {
            $(this).animate({ 'zoom': 1 }, 400);
        });
    });
    

    ​or you may do like this if zoom in and out buttons are used :

    $("#ZoomIn").click(ZoomIn());
    
    $("#ZoomOut").click(ZoomOut());
    
    function ZoomIn (event) {
    
        $("#div img").width(
            $("#div img").width() * 1.2
        );
    
        $("#div img").height(
            $("#div img").height() * 1.2
        );
    },
    
    function  ZoomOut (event) {
    
        $("#div img").width(
            $("#imgDtls").width() * 0.5
        );
    
        $("#div img").height(
            $("#div img").height() * 0.5
        );
    }
    

提交回复
热议问题