I'm making a house designing game of sorts and i'm wondering how i could make it so that there is a png of a flower pot in a set position.
When clicked a draggable png of the flower pot appears and the player can do it indefinitely.
this is my code so far:
HTML
<div id="buttons">
<span class="button" id="up">up</span>
<span class="button" id="down">down</span>
<div><span>Z-index: </span><span id="index"></span></div>
</div>
<div id="images">
<img src="http://i67.tinypic.com/wum2y8.jpg" id="background">
<img class="draggable" src="http://i64.tinypic.com/jac9sj.jpg">
<img class="draggable" src="http://i64.tinypic.com/se6gia.jpg">
<img class="draggable" src="http://i65.tinypic.com/205p9v6.jpg">
<!--more img.draggable elements -->
</div>
JS
$(function() {
$(".draggable").draggable();
});
var selectedLayer;
$(".draggable").click(function() {
selectedLayer = this;
$("#index").html(parseInt($(selectedLayer).css("z-index")))
})
$("#up").click(function() {
x = parseInt($(selectedLayer).css("z-index")) + 1;
$(selectedLayer).css('z-index', x);
$("#index").html(x)
}) //ends function
$("#down").click(function() {
x = parseInt($(selectedLayer).css("z-index")) - 1;
$(selectedLayer).css('z-index', x);
$("#index").html(x)
})
full example: https://jsfiddle.net/okcjt5vf/312/
Thank you for any help.