简体   繁体   中英

Mimic window load event in Jquery mobile

I need to pull the width of images, which I can only do after the window load event.

Of course, this doesn't fire in jQuery Mobile, so I need an equivalent.

I have:

$(window).load(function(){
            var diff = $('div.canvas img.photo').get(1).width;
            console.log(diff);
        });

which obviously works fine when not loaded through AJAX, but I have cycled though the various events Jquery Mobile provides, and I can't get it to return the correct value.

$(document).live('pageshow', function(){
        var diff = $('div.canvas img.photo').get(1).width;
        console.log(diff);
    });

Essentially it needs to return the width of an image on a newly loaded page.

pageLoad Event.

http://jquerymobile.com/demos/1.0.1/docs/api/events.html

Will need to wire it up though

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM