在DIV中获取所有图片并修改其大小

    技术2022-05-20  43

     function  imgSize(strWidth,strHeight){               var img;               img = $("#strImg img");     --jquery , div的id 为strImg

                for(var i=0; i<img.length;i++){                  image = img[i];               if(image.width>0 && image.height>0){                  if(image.width>strWidth){                      image.style.width=strWidth;                      image.style.height=strHeight;      --一定要加上Style                  }else{                      image.style.width=image.style.width;                      image.style.height=image.style.height;                  }               }else{                   if(image.height>strHeight){                                          image.style.width=strWidth;                       image.style.width=strHeight;                   }else{                      image.style.width=image.style.width;                      image.style.height=image.style.height;                   }               }              }            window.οnlοad=imgSize(200,200);           }


    最新回复(0)