jquery怎么给一个DIV设置坐标
1个回答
展开全部
<!DOCTYPE HTML>
<html>
<head>
<meta charset=UTF-8>
<meta name="keywords" content="白菜编辑部">
<title>白菜编辑部</title>
<style type="text/css">
</style>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
jQuery (function ($)
{
var div = $ ('div');
$ ('button').click (function ()
{
var left = parseFloat (div.css ('left')) || 0, top = parseFloat (div.css ('top')) || 0;
div.css (
{
left : left + 10 + 'px',
top : top + 10 + 'px'
});
})
});
</script>
</head>
<body>
<div style="position: absolute; width: 200px; height: 200px; border: 1px solid black;">div</div>
<button>move</button>
</body>
</html>
<html>
<head>
<meta charset=UTF-8>
<meta name="keywords" content="白菜编辑部">
<title>白菜编辑部</title>
<style type="text/css">
</style>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
jQuery (function ($)
{
var div = $ ('div');
$ ('button').click (function ()
{
var left = parseFloat (div.css ('left')) || 0, top = parseFloat (div.css ('top')) || 0;
div.css (
{
left : left + 10 + 'px',
top : top + 10 + 'px'
});
})
});
</script>
</head>
<body>
<div style="position: absolute; width: 200px; height: 200px; border: 1px solid black;">div</div>
<button>move</button>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询