Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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;
        }                       
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Real #image #width #JavaScript
ADD COMMENT
Topic
Name
2+4 =