Moloch,
Сообщение от Moloch
|
e.position
|
position только для чтения -- используйте css
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.segment {
background: #FFCC00;
width: 100px;
height: 100px;
position: absolute;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
$(function() {
var defaultCoords = [{
pos_x: 10,
pos_y: 20
}, {
pos_x: 30,
pos_y: 40
}];
$(".segment").each(function(indx, s) {
var e = $(s);
e.css({
left: defaultCoords[indx]["pos_x"],
top: defaultCoords[indx]["pos_y"]
})
})
});
</script>
</head>
<body>
<div class="segment">1</div>
<div class="segment">2</div>
</body>
</html>