Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Real image width with JavaScript

// width in pixels
function setImagesWidth(id, width)
{
    var images = document.getElementById(id).getElementsByTagName("img");
    var newWidth = width + "px";
    for (var i = 0; i < images.length; ++i)
    {
        if (images[i].clientWidth > width)
        {
            images[i].style.width = newWidth;
        }                       
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: mdn getcurrentposition 
Javascript :: js localstorage clear 
Javascript :: NextJS add lang attribute to HTML tag 
Javascript :: js array map skip element 
Javascript :: javascript function with parameters 
Javascript :: js regex return null 
Javascript :: if without else javascript 
Javascript :: decode jwt token without library 
Javascript :: accessing json data 
Javascript :: js key event 
Javascript :: make image onclick in vuejs 
Javascript :: how to name a javascript variable 
Javascript :: angular $http abort request 
Javascript :: how to disable button if errors object isnt empty in react hook form 
Javascript :: javascript keylogger 
Javascript :: how to proxy enable in server nodejs 
Javascript :: add two empty arrays javascript 
Javascript :: launch.json 
Javascript :: what is form data in javascript 
Javascript :: jquery check valid link 
Javascript :: javascript random number 
Javascript :: toast js 
Javascript :: react map array 
Javascript :: Get the values from the "GET" parameters 
Javascript :: new js 
Javascript :: Why do you need JSON 
Javascript :: jq break line 
Javascript :: json object array 
Javascript :: string equals javascript 
Javascript :: form changes button enable reactive forms 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =