开发者

loading and replacing the image in jquery

I h开发者_StackOverflowave low resolution image which is loaded first,once it is loaded i need to replace it with a high resolution image.

I try to do so in html img tag but in throws error saying

Uncaught TypeError: Cannot read property 'width' of undefined


In order to replace the image try using

$('#Image').find('img').attr('src', ['/ImagePath/', NewImageName].join('')); 

Or may be you can consider changing just the src

$('#Image').attr('src', '/ImagePath/NewImageName');


JavaScript only:

document.getElementById('idOfYourImg').src = '/new/path.png';

jQuery:

$('#idOfYourImg').attr('src', '/new/path.png');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜