Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to set the size of the picture by JavaScript

Shulou Source: shulou.com Published: 2022-05-31 11:52:12 10月04日 Update

This article mainly explains the "JavaScript how to set the size of the picture", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "JavaScript how to set the size of the picture" bar!

JavaScript sets the size of the picture: first create a HTML sample file; then introduce the picture through img; finally, change the size of the picture dynamically through the "setInterval (function warp () {...}" method.

This article operating environment: windows7 system, javascript1.8.5 version, DELL G3 computer

How does JavaScript set the image size?

JavaScript resizes the picture

Dynamically resize the picture window.function () {var natives 2; var renders 1; var control=true; setInterval (function warp () {if (control==true) {naught +) } else {nmuri;} if (naughty three hundred) control=false;// if (nasty mile1) control=true; if (control==true) {oPic.width+=1; oPic.height+=1 } else {oPic.width-=1; oPic.height-=1;}, 30); / / call the warp function every 30 milliseconds}

Thank you for your reading, the above is the content of "how to set the size of the picture in JavaScript". After the study of this article, I believe you have a deeper understanding of how to set the size of the picture in JavaScript, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Pictures sizes learning content dynamics methods functions that is ideas situations files articles more environment computers knowledge knowledge points examples articles systems Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Xiaomi Huawei MariaDB NVidia