Eric
Eric

Reputation:

My JQuery functions are not working - What's wrong with my syntax?

jQuery.preloadImages = function() { for(var i = 0; i<arguments.length; i++) jQuery("<img>").attr("src", arguments[i]); }

$(function() {

$('#background-wrap img').css('opacity',0);
$('#background-wrap img').animate({ opacity: 1}, 3000);

});

It's not doing performing of the functions that are in the code. Where did I mess up the syntax because I can seem to figure it out myself?

Cheers!

Upvotes: 0

Views: 72

Answers (2)

genesis
genesis

Reputation: 50982

<img> 

should be replaced with img

jQuery.preloadImages = function() { for(var i = 0; i<arguments.length; i++) jQuery("img").attr("src", arguments[i]); }

$(function() {

$('#background-wrap img').css('opacity',0);
$('#background-wrap img').animate({ opacity: 1}, 3000);

});

Upvotes: 0

Rob
Rob

Reputation: 7717

Instead of:

jQuery('<img>')

Use:

jQuery('img')

Also, read jQuery Plugin Authoring for information about how to extend jQuery. In the code above preloadImages() is also not being called.

Upvotes: 1

Related Questions