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 1044633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:51:31+00:00 2026-05-16T15:51:31+00:00

Evening all – Whats the best way to access an image’s height and width

  • 0

Evening all – Whats the best way to access an image’s height and width dynamically .
I want to add 20% to an images width and height and animate when the surrounding div is hovered, I guess I need to use ‘this’, but not sure how to access the image.

Any help greatfully received.

Cheers Paul

  • 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-16T15:51:32+00:00Added an answer on May 16, 2026 at 3:51 pm

    You could do something like this, using .height() and .width() with function arguments:

    $("img").hover(function() {
        $(this).height(function(i, h) { return h * 1.2; })
               .width(function(i, w) { return w * 1.2; });
    }, function() {
        $(this).height(function(i, h) { return h / 1.2; })
               .width(function(i, w) { return w / 1.2; });
    });​
    

    You can give it a try here, if you wanted a smooth animation you could store the initial height/width and .animate(), like this:

    $("img").each(function() {
        $.data(this, 'size', { width: $(this).width(), height: $(this).height() });
    }).hover(function() {
        $(this).stop().animate({ height: $.data(this,'size').height*1.2, 
                                 width: $.data(this,'size').width*1.2 });
    }, function() {
        $(this).stop().animate({ height: $.data(this,'size').height, 
                                 width: $.data(this,'size').width });
    });​
    

    You can give it a try here, be sure to run either of these options in $(window).load(), and not $(document).ready(), since the dimensions may not be loaded yet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

good evening. ingore all other elements, I want get first image in each foreach.
Good Evening All, I've created the following stored procedure: CREATE PROCEDURE AddQuote -- Add
Evening all, I've got a bit of an issue with some pop up images.
Good evening all. I'm attempting to dynamically populate a select_tag call in my rails
Evening all, Before i make my site live i obviously want to ensure it's
Evening all! I'm optimizing my website, and I'm running into some peculiar behaviour. Before,
Good evening all, I've been working on an MD5 tool in C# that takes
Good evening, I'm having an issue with Masonry. This is all my relevant code:
I have been trying to connect to mysql all evening using PHP. I know
Good evening! Been searching all over, and I'm afraid I've just got something completely

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.