如果没用过mootools 也可以看懂逻辑 看看下面的逻辑对不??怎么运行没反应啊??
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body>
<div id=a style="width:100px;height:100px;background:red;"></div>
<script type="text/javascript" src="../mootools-1.2.3-core-nc.js"></script>
<style>

</style>
<script>
var a=$('a');
$(document.body).addEvents({
click:function(e){
e=new Event(e);
a.setStyles({
position:absolute,//先设为绝对定位
left:e.page.x,//再设置left
top:e.page.y//再设置top
})
}
})
</script>
</body>
</html>

解决方案 »

  1.   

    a.setStyles({
      position:'absolute',
      left:e.page.x + 'px',
      top:e.page.y + 'px'
    })
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    </head>
    <body>
    <div id=a style="width:100px;height:100px;background:red;"></div>
    <script type="text/javascript" src="../mootools-1.2.3-core-nc.js"></script>
    <style>

    </style>
    <script>
    var a=$('a');
    $(document.documentElement).addEvents({//这换成documentElement就可以了  body不行 不知道为什么
    click:function(e){
    e=new Event(e);
    a.setStyles({
    position:'absolute',//这要交引号
    left:e.page.x,
    top:e.page.y
    })
    }
    })

    </script>
    </body>
    </html>