Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6716887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:47:13+00:00 2026-05-26T08:47:13+00:00

I am using a slideshow script that needs the dimensions of every image for

  • 0

I am using a slideshow script that needs the dimensions of every image for it to work properly. There are going to be some 50+ images that a client would have to add dimensions too.

Is there a script I can use that will find the width of all the images in an unordered list with an ID of “scroller”, and then set the width just like it’d be set within the image tag?

If somebody could help me write it, and possibly explain what each section does, I would greatly appreciate it.

And if you are looking for code, here it is.

Before JQuery code.

<ul id="scroller">
<li><img src="image.jpg"></li>
<li><img src="image.jpg"></li>
<li><img src="image.jpg"></li>
<li><img src="image.jpg"></li>
</ul>

After JQuery code.

<ul id="scroller">
<li><img src="image.jpg" width="100"></li>
<li><img src="image.jpg" width="350"></li>
<li><img src="image.jpg" width="70"></li>
<li><img src="image.jpg" wudth="250"></li>
</ul>

The images would have different widths, but all the same height.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:47:13+00:00Added an answer on May 26, 2026 at 8:47 am

    Yes you could. It’s very intuitive really.

    $('image selector').width(); //to access width
    $('image selector').width(N); //to set width to Npx.
    

    In order to loop through all of them, you’ll use .each().

    $('#scroller img').each(function() {
        //Do stuff width each image. $(this).
    }
    

    You may want to know that you can grab the existing width and set it, but only after the element is fully loaded. This may cause a bit of jumpiness on older browsers, so it would be worth it to hide the images, grab the existing dimensions, do the transformation, and then fade them all in at the same time or something pretty looking like that.
    Thanks @Whetstone


    $(function() {
    
        $('#scroller img').each(function() {
            $(this).attr('width', $(this).width());
        });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a simple script that displays images in a jquery slideshow -
I'm using a script that uses DD's Ultimate Fade-in Slideshow: http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm It uses jquery,
I'm creating a slideshow using javascript that fades images. Awhile back, I discovered that
I have a slideshow built using the jbgallery script that I am trying to
I am using one of snook.ca script for simple slideshow. Here it is in
I'm using a third-party AJAX slideshow for a website that takes an RSS feed
I'm using SimpleXML to add new images childs for a slideshow tool on my
Using ASP.NET MVC there are situations (such as form submission) that may require a
I have a div that contains a slideshow. ( http://film.robinhoodtax.org/issues/education ) I am using
I want to create an image slideshow using WPF and C#, but I don`t

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.