Reputation:
This script doesn't work.. Where is the error? With .onload it's OK
$(document).ready(function() {
var img = new Image();
img.onClick = function() {
$("div").animate({width:this.width, height:this.height});
}
img.src = 'http://www.google.com/intl/en_ALL/images/logo.gif';
});
thanks for the aid.
Upvotes: 0
Views: 700
Reputation: 73966
Try this:
var img = new Image();
img.src = 'http://www.google.com/intl/en_ALL/images/logo.gif';
$(img).live("click", function() {
$("div").animate({
width: $(this).width(),
height: $(this).height()
}, 1000);
}).appendTo('body');
Upvotes: 0
Reputation: 1764
Since you're using jQuery anyway, why not just stick with it:
$(function(){ // this is a shortcut for $(document).ready
var img = $('<img src="http://www.google.com/intl/en_ALL/images/logo.gif>');
img.on('click', function(){
$('div').animate(...)
})
img.appendTo('body')
})
Upvotes: 1