Pingui
Pingui

Reputation: 1496

Exchanging an image with jQuery?

Can anybody tell me why the following code (also see jsfiddle) does not replace 1tw.gif with 2tw.gif? It should show "2" instead of "1"...

<img id="pic" src="http://www.drewgreenwell.com/images/sample/1tw.gif" alt="" width="90%"/>

<script>
$(document).ready(function(){
$('#pic').attr('scr', 'http://www.drewgreenwell.com/images/sample/2tw.gif');
});
</script>

Thank you!

Upvotes: 0

Views: 57

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82251

You have typo. scr should be src:

$('#pic').attr('src', 'http://www.drewgreenwell.com/images/sample/2tw.gif');

Demo

Upvotes: 4

Related Questions