• Tags , ,
  •         
  • www.breakyizhan.com
  •    

    Jquery实现点击图片放大和缩小

    网站有时候的图片比较小,但是放大又不好看,所以我们可以用Jquery来实现点击图片放大和缩小,源代码如下:

    <html>
    <head>
    <meta charset="utf-8">
    <script type='text/javascript' src='https://www.breakyizhan.com/wp-includes/js/jquery/jquery.min.js'>
    </script>
    <style>
    .max{width:100%;height:auto;} .min{width:600px;height:auto;}
    </style>
    <script>
    $(function() {
    $('img').click(function() {
    $(this).toggleClass('min');
    $(this).toggleClass('max');
    });
    });
    </script>
    </head>
    <body>
    <img class='min' src='https://www.breakyizhan.com/wp-content/uploads/2017/11/git.png'>
    </body>
    </html>
    

     
    转载请保留页面地址:https://www.breakyizhan.com/jquery/5412.html