I'm trying to find the displayed width/height of an image, but keep getting slightly off values.
After researching it seems it should be in a window.load function, so here's what I have:
- $(window).load(function() {
- $(function() {
- $('#item0_%id% ul li#itemimg0_%id% img').load(function() {
- var w = this.width;
- var h = this.height;
- $(this).removeAttr('width').removeAttr('height');
- var image = $('#item0_%id% ul li#itemimg0_%id% img');
- var imgwd = image.width();
- console.log('Wd: ' + imgwd);
- var imght = $(this).height();
- console.log('Ht: ' + imght);
- $(this).attr({height:h, width:w});
- var newsz = imgwd + 'px x ' + imght + 'px';
- $('#suggimgsize_%id%').append(newsz);
- });
- });
- });
FYI - when I place this function in doc.ready, it gives a width of 900, which is entire window width.
When running as shown above, I get nothing in console output.
I'm targeting the left dark blue image, trying to get a width that matches 272px, but I need some help w/ my code.
Thanks, Bill