Показать сообщение отдельно
  #2 (permalink)  
Старый 21.06.2018, 20:12
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,070

droppable ship
Retro_1477,

<!DOCTYPE html>

<html>
<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <style type="text/css">
td, div.ship{
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  border: 1px solid #000000;
  text-align: center;
  background-color: rgba(30, 144, 255, 1);
  margin: 0;
  padding: 0;
}
div.ship {
  background-color: rgba(105, 105, 105, 1);
  display: inline-block;
  margin-right: 2px;
}

td div.ship {
   display: block;
   margin: 0;
}
</style>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
  <script>
$(function() {
var mytable = $('<table/>').appendTo('body'), tr,
td = $.map(Array(100),function(el,i) {
    i % 10 || (tr = $('<tr/>').appendTo(mytable));
    return $('<td/>').appendTo(tr);
}),
ship = $.map(Array(10),function(i) {
  return  $('<div class="ship"/>').appendTo('body');
});

$(td).droppable({
        accept: ".ship",
        drop: function(event, ui) {
            ui.draggable.appendTo(this)
        }
    });
$(ship).draggable({
        cancel: "a.ui-icon",
        revert: "invalid",
        containment: "document",
        helper: "clone",
        cursor: "move"
    });
});
  </script>
</head>

<body>


</body>
</html>
Ответить с цитированием