0

我有几个可拖动的 div 加载时随机放置在页面上

我希望通过单击链接将这些 div 重新排列到预先指定的位置,我该怎么做呢?

这是jsfiddle:http: //jsfiddle.net/BbKsq/7/

$("#web01,#web02").each(function () {
var randHigh = Math.floor(Math.random() * ($(window).height() - 200));
var randWide = Math.floor(Math.random() * ($(window).width() - 200));
$(this).offset({
    top: randHigh,
    left: randWide
4

1 回答 1

1

如果您已经生成了这么多代码,有什么问题?

$('#organize').click(function() { // just add id="organize" somewhere
    $('#web01').offset({
        top: 20, // this is that pre-specified position
        left: 20
    });
});

我错过了什么吗?

于 2013-04-26T11:05:26.513 回答