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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:42:49+00:00 2026-05-24T18:42:49+00:00

$(img).click(function () { $(#galleryImg).html(<img src=’images/full_size/ + selectedImg + ‘ alt=’ + selectedImg + ‘

  • 0
$("img").click(function () {
    $("#galleryImg").html("<img src='images/full_size/" + selectedImg + "' alt='" + selectedImg + "' />");
    var imgHeight = $("#galleryImg img").height();
}

The method I’m using right now is not working and I can’t use $(this) because the image that I want the height from is different from the image I am clicking on. And to complicate it a little bit more, the image I want the height from is having its html img tag being created within the function.

The whole piece of code of the relevant area is as below

$("img").click(function () {
    $("div#blackOut").fadeTo(550, 0.8);
    $("div#whiteBox").fadeTo(550, 1);

    var browserHeight = $(window).height();
    var browserWidth = $(window).width();

    var imgName = $(this).attr("src");

    var imgArray = $(this).attr('src').split('\/');
    var selectedImg = imgArray[imgArray.length-1];

    $("#galleryImg").html("<img src='images/full_size/" + selectedImg + "' alt='" + selectedImg + "' />");

    $("#galleryImg img").load(function() {
        var thatHeight = $("#galleryImg img").height();

        alert(thatHeight);
    });

    var top = (browserHeight - (imgHeight + 50)) / 2;
    var width = imgHeight + 50;
    var marginLeft = -(width / 2);

    var top = top + "px";
    var width = width + "px";
    var marginLeft = marginLeft + "px";

    $("#whiteBox").css("top", top);
    $("#whiteBox").css("width", "width");
    $("#whiteBox").css("margin-left", "marginLeft");
});
  • 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-24T18:42:49+00:00Added an answer on May 24, 2026 at 6:42 pm

    You’ll need to wait for the image to load before getting its height:

    $("#galleryImg").html("<img src='images/full_size/" + selectedImg + "' alt='" + selectedImg + "' />");
    $("#galleryImg img").load(function() {
        var imgHeight = $(this).height();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$(document).ready(function(){ $('.choices a img').click(function(e) { var url = $(this).attr('href') + ' .con_cen2'; $('.con_cen').html('loading...').load('signup.html'); e.preventDefault();
With jQuery, i change the src of an image on click $(#thumb li img).click(function()
I have the following function. $(function() { $(.sectionHeader:gt(0)).click(function() { $(this).next(.fieldset).slideToggle(fast); }); $(img[alt='minimize']).click(function(e) { $(this).closest(table).next(.fieldset).slideUp(fast);
var thumbs = document.getElementsByTagName(img); for (var i=0; i<thumbs.length; i++) { Core.addEventListener(thumbs[i], click, function() {alert(i);});
$('img').click(function(){ var add_to_list = $(this); // database query for element }); Currently add_to_list is
$(document).ready(function(){ $('img').click(function(){ var class = $(img).attr(class); console.log(class); }); }); Back with another question. I
HTML: <div id=media-photo> <img src=/uploads/photos/16.jpg alt= /> </div> <a href=/uploads/photos/5.jpg class=img> <img src=/uploads/photos-thumbs/5.jpg alt=
Using this jQuery: $('#mycarousel li img').click(function(){ $('#video').empty(); var newId = $(this).attr('id'); newId = newId.replace('vid','');
I have done a very simple gallery using: $('#thumbs img').click(function(){ $('#mainimg img').attr('src',$(this).attr('src').replace('thumb','large')); }); but
My jQuery code: $('.Img').click(function() { alert('Test'); }); $().ready(function() { $.ajax( { type : 'POST',

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.