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

  • Home
  • SEARCH
  • 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 9138061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:12:28+00:00 2026-06-17T09:12:28+00:00

I am having trouble setting my css with the image inside my div. I

  • 0

I am having trouble setting my css with the image inside my div.

I have

<div class='test'>

   <a href='#'>   <img src='haha.jpg'/>   </a>
   <a href='#'>   <img src='imageINeed.jpg'/>  </a>

</div>

<div class='test'>

   <a href='#'>   <img src='haha.jpg'/>   </a>
   <a href='#'>   <img src='imageINeed1.jpg'/>  </a>

</div>

<div class='test'>

   <a href='#'>   <img src='haha.jpg'/>   </a>
   <a href='#'>   <img src='imageINeed2.jpg'/>  </a>

</div>

My jquery below will select the second image

imageSize could be varies.

  $('.test).each(function(){

        $(this).find('img:eq(1)').width(imageSize);
  })

However, there are times that I only have 1 <a> tag inside the test div.

    <div class='test'>
       <a href='#'>   <img src='imageINeed2.jpg'/>  </a>
   </div>

eq(1) won’t select the img if I only have 1 <a> tag

I have tried

$('.test).each(function(){
    $(this).find('img:nth-last-child').width(imageSize);
})

It won’t do it. Are there anyways to do it? Thanks so much!

  • 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-06-17T09:12:29+00:00Added an answer on June 17, 2026 at 9:12 am

    Use :last selector:

    $(".test").find("img:last").width(imageSize);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML markup. <div class=caption> <img class='active' alt='My Caption' src='path/to/image' />
I am having trouble setting up my functions in a class when I want
I am having trouble setting up jpa mappings for some entities. I have a
I'm having trouble setting up my css to display my page correctly. I want
I'm having trouble with setting 2 div's position without one of them moving to
I'm new in asp.net. And I am having trouble setting my background image. Here's
I'm having trouble setting up Teamcity and Git. I have a git repo checked
I'm having a bit of trouble setting up some CSS stuff. Here is my
I'm having trouble setting 2 positions on a scroll function using offset. I have
I am having trouble setting this up for multiple divs. I have it here

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.