Reputation: 4633
I tried to run this both locally and in the jsfiddle without success. Am I missing something? I want to make this image move to the right.
HTML
<div id="game">
<img id="asd" src="http://i.imgur.com/ApuSWMC.png" alt="torch">
</div>
JS
$(document).ready(function () {
$('#asd').click(function () {
$('#asd').animate({
left: "+=100px"
}, 'fast');
});
});
I thought it has to do with the selector, tried both by id
and img
, tried changing it to a div
, without success. Any idea what might be wrong?
Upvotes: 1
Views: 23
Reputation: 45
yes, position absolute or relative will work here to the id asd.
Upvotes: 1
Reputation: 92983
You must position the element (relatively or absolutely) before you can change its position:
#asd {
position: absolute; // or position: relative;
}
http://jsfiddle.net/mblase75/KrA3D/1/
Upvotes: 1