logo       

Re: [jQuery] $(document).load() and friends: msg#01148

lang.javascript.jquery

Subject: Re: [jQuery] $(document).load() and friends

Mika Tuupola wrote:
> Am I missing something obvious or why does .load() not seem to
> trigger anything. I am sure $('img').load(function() { something });
> used to work before. This is not the case with 1.0.2.
>
> Check the page below. I get only "ready" at firebug console. So none
> of the load()'s get executed.
>
> http://www.appelsiini.net/~tuupola/jquery/panview/load.html
>
> -cut-
> $(document).ready(function() {
> console.log('ready');
> });
> $('img').load(function() {
> console.log('img load');
> });
> $('p').load(function() {
> console.log('p load');
> });
> $(document).load(function() {
> console.log('document load');
> });
> -cut-
>

$('img') and $('p') won't find anything until the document
is ready, try:

$(document).ready(function() {
console.log('ready');

$('img').load(function() {
console.log('img load');
});
$('p').load(function() {
console.log('p load');
});
});

I'm not sure about $(document).load though, never used it!

- Mark Gibson


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise