Users Pricing

forum

Home Forums Retrieve original image length & height with jquery? – MindStick

Retrieve original image length & height with jquery?

Anonymous User 2208 30 Jan 2015

I have a display thumbnail at 250px by 250px. I want to be able to retrieve its original width and height when clicking on the thumbnail.

I tried doing this:

$(function() {
    $(".img_section").on('click',function() {
        var img = $(this).children(".test_img").attr("src");
        theImg.src =img.attr("src");
 
        var imgNaturalWidth = theImg.width();
        var imgNaturalHeight = theImg.height();
 
        alert(imgNaturalWidth);
        alert(imgNaturalHeight);
}) // not working

Any help will be appreciated, thanks.


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md