我试图双击,拖放然后保存到本地存储工作任何人都有一个好主意?
<img ondblclick="init (this.id)" src="http://images.dailytech.com/nimage/G_is_For_Google_New_Logo_Thumb.png" id="goog" class="icons">
<img ondblclick="init (this.id)" src="http://images.dailytech.com/nimage/G_is_For_Google_New_Logo_Thumb.png" id="glo" class="icons">
<img ondblclick="init (this.id)" src="http://images.dailytech.com/nimage/G_is_For_Google_New_Logo_Thumb.png" id="g" class="icons">
var sPositions = localStorage.positions || "{}",
positions = JSON.parse(sPositions);
$.each(positions, function (id, pos) {
$("#" + id).css(pos)
})
function init (id) {
$("#" + id).draggable({
grid: [ 15, 15 ],
stop: function (event, ui) {
positions[this.id] = ui.position
localStorage.positions = JSON.stringify(positions)
}
})
};
http://jsfiddle.net/caa888/Lyfqwj1c/8/
感谢