Показать сообщение отдельно
  #9 (permalink)  
Старый 09.01.2016, 01:46
Профессор
Отправить личное сообщение для Keramet Посмотреть профиль Найти все сообщения от Keramet
 
Регистрация: 30.12.2015
Сообщений: 194

что-то типа этого (если я правильно понял идею). Нажми на кнопку - получишь результат
<!DOCTYPE html>
<html lang="ru">
<head>
	<meta charset="UTF-8"/>
	<title>Двигай </title>
	<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
	<style>
		div { 	border: 1px solid black; position: absolute; background: red;}
	</style>
	<script type="text/javascript">
		window.onload = function() {
			document.getElementById('myBtn').onclick = function() {
				var addTop = 10, addLeft = 10;
				var $allDiv = $('div[class^=my]').each(function() {
					this.style.top = parseInt(this.style.top) + addTop + 'px';
					this.style.left = parseInt(this.style.left) + addLeft + 'px';
				});
			}
		};
	</script>
</head>

<body>
<input type='button' id='myBtn' value='Click me'>
<div class="my1" style="top: 74px; left: 115px;">11</div>
<div class="my2" style="top: 45px; left: 15px;">22</div>
<div class="my3" style="top: 52px; left: 315px;">33</div>
<div class="my4" style="top: 34px; left: 225px;">44</div>
</body>
</html>

Последний раз редактировалось Keramet, 09.01.2016 в 01:49.
Ответить с цитированием