JavaScript Draggable div inside table

I have this html code i want to make the color divs draggable and then fit them in the table cell aside

the green div should fit 2 cell spaces, the light blue 3 cell spaces, the yellow 4 cell spaces and the dark blue 5 cell spaces.

i have the draggable code but how can i make it so it would make them divs fit and stay in the table cell

enter image description here

< script type = "text/javascript" >
  var turno = 0;
var bomba = 1;
var bombaClick = 0;
var arregloLetras = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'];

$('#bomb-attack').on('click', function() {
  bombaClick = 1;
});

$('#oponentBoard td#options').on('click', function() {
  var celda = $(this).attr('class');
  var datos = celda.split('-');
  $(this).css('background-color', '#FF0000');
  if (bombaClick == 1) {
    if (bomba == 1) {
      selectAround(datos[0], datos[1]);
      bomba = 0;
      $('#bomb-attack').attr("disabled", true);
    }
  }
});

function selectAround(letra, numero) {
  var indexLetra = arregloLetras.indexOf(letra);
  var indexNumero = parseInt(numero);
  var indexLetraAtras, indexLetraAdelante, indexNumeroAdelante, indexNumeroAtras = -1;

  if (indexLetra > 0)
    indexLetraAtras = indexLetra - 1;
  if (indexLetra < 9)
    indexLetraAdelante = indexLetra + 1;

  if (indexNumero > 1)
    indexNumeroAtras = indexNumero - 1;
  if (indexNumero < 10)
    indexNumeroAdelante = indexNumero + 1;

  if (indexLetraAtras != -1) {
    $('#oponentBoard td.' + arregloLetras[indexLetraAtras] + '-' + indexNumero).css('background-color', '#FF0000');
    if (indexNumeroAdelante != -1)
      $('#oponentBoard td.' + arregloLetras[indexLetraAtras] + '-' + indexNumeroAdelante).css('background-color', '#FF0000');
    if (indexNumeroAtras != -1)
      $('#oponentBoard td.' + arregloLetras[indexLetraAtras] + '-' + indexNumeroAtras).css('background-color', '#FF0000');
  }
  if (indexLetraAdelante != -1) {
    $('#oponentBoard td.' + arregloLetras[indexLetraAdelante] + '-' + indexNumero).css('background-color', '#FF0000');
    if (indexNumeroAdelante != -1)
      $('#oponentBoard td.' + arregloLetras[indexLetraAdelante] + '-' + indexNumeroAdelante).css('background-color', '#FF0000');
    if (indexNumeroAtras != -1)
      $('#oponentBoard td.' + arregloLetras[indexLetraAdelante] + '-' + indexNumeroAtras).css('background-color', '#FF0000');
  }
  if (indexNumeroAdelante != -1)
    $('#oponentBoard td.' + letra + '-' + indexNumeroAdelante).css('background-color', '#FF0000');
  if (indexNumeroAtras != -1)
    $('#oponentBoard td.' + letra + '-' + indexNumeroAtras).css('background-color', '#FF0000');
}

$(function() {
  //$( ".draggable" ).resizable();
  $(".draggable").draggable({
    revert: 'invalid',
    helper: "clone",
    snap: "#drop_here td",
    opacity: 0.7
  });

  $("#drop_here td").droppable({
    // accept only from left div,
    // this is necessary  to prevent clones duplicating inside droppable
    accept: '#left .draggable',
    drop: function(event, ui) {
      // 4 append clone to droppable
      $(this).append(
        // 1 clone draggable helper
        $(ui.helper).clone()
        // 2 make the clone draggable
        .draggable({
          containment: "parent"
        })
        // 3 make the clone resizable
        .resizable());
    }
  });
}); < /script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" target='_blank' href="http://test.jobfeedpro.com/battleship/includes/css/bootstrap.css">
  <link rel="stylesheet" target='_blank' href="http://test.jobfeedpro.com/battleship/includes/css/style-override.css">
  <link rel="stylesheet">
  <link rel="stylesheet" target='_blank' href="http://test.jobfeedpro.com/battleship/includes/css/jquery-ui.css">

  <script type="text/javascript" src="https://www.google.com/jsapi"></script>
  <script type="text/javascript" src="http://test.jobfeedpro.com/battleship/includes/jquery/jquery-2.1.3.min.js"></script>
  <script type="text/javascript" src="http://test.jobfeedpro.com/battleship/includes/jquery/jquery-ui.js"></script>
  <script type="text/javascript" src="http://test.jobfeedpro.com/battleship/includes/js/bootstrap.min.js"></script>
</head>

<div class="container">
  <div class="row">
    <div class="col-md-3">
      <div class="well well-md">
        <h3>Boats</h3>
        <div class="draggable boat boat-small ui-draggable ui-draggable-handle"></div>
        <div class="draggable boat boat-medium ui-draggable ui-draggable-handle"></div>
        <div class="draggable boat boat-medium ui-draggable ui-draggable-handle"></div>
        <div class="draggable boat boat-large ui-draggable ui-draggable-handle"></div>
        <div class="draggable boat boat-xlarge ui-draggable ui-draggable-handle"></div>
      </div>
      <!-- <div class="well well-md"> -->
      <div class="well well-md">
        <h3>Attack</h3>
        <button id="bomb-attack" class="btn btn-danger">Bomb!!</button>
      </div>
      <!-- <div class="well well-md"> -->
    </div>
    <!-- <div class="col-md-3"> -->

    <div class="col-md-9 col-md-offset-0 well well-md">
      <div class="col-md-6">
        <div id="yourBoard" class="boards">
          <h3>My Board</h3>
          <table id="drop_here" class="table table-bordered board-bg">
            <tbody>
              <tr>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable">1</td>
                <td width="1%" class="ui-droppable">2</td>
                <td width="1%" class="ui-droppable">3</td>
                <td width="1%" class="ui-droppable">4</td>
                <td width="1%" class="ui-droppable">5</td>
                <td width="1%" class="ui-droppable">6</td>
                <td width="1%" class="ui-droppable">7</td>
                <td width="1%" class="ui-droppable">8</td>
                <td width="1%" class="ui-droppable">9</td>
                <td width="1%" class="ui-droppable">10</td>
              </tr>
              <tr>
                <td width="1%" class="ui-droppable">A</td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
              </tr>
              <tr>
                <td width="1%" class="ui-droppable">B</td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
              </tr>
              <tr>
                <td width="1%" class="ui-droppable">C</td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
              </tr>
              <tr>
                <td width="1%" class="ui-droppable">D</td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
              </tr>
              <tr>
                <td width="1%" class="ui-droppable">E</td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
              </tr>
              <tr>
                <td width="1%" class="ui-droppable">F</td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
              </tr>
              <tr>
                <td width="1%" class="ui-droppable">G</td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
              </tr>
              <tr>
                <td width="1%" class="ui-droppable">H</td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
              </tr>
              <tr>
                <td width="1%" class="ui-droppable">I</td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
              </tr>
              <tr>
                <td width="1%" class="ui-droppable">J</td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
                <td width="1%" class="ui-droppable"></td>
              </tr>
            </tbody>
          </table>
        </div>
        <!-- <div id='yourBoard' class='boards'> -->
      </div>
      <!-- <div class="col-md-6"> -->

      <div class="col-md-6">
        <div id="oponentBoard" class="boards">
          <h3>Oponent</h3>
          <table class="table table-bordered board-bg">
            <tbody>
              <tr>
                <td width="1%"></td>
                <td class="ui-droppable" width="1%">1</td>
                <td class="ui-droppable" width="1%">2</td>
                <td class="ui-droppable" width="1%">3</td>
                <td class="ui-droppable" width="1%">4</td>
                <td class="ui-droppable" width="1%">5</td>
                <td class="ui-droppable" width="1%">6</td>
                <td class="ui-droppable" width="1%">7</td>
                <td class="ui-droppable" width="1%">8</td>
                <td class="ui-droppable" width="1%">9</td>
                <td class="ui-droppable" width="1%">10</td>
              </tr>
              <tr>
                <td width="1%">A</td>
                <td id="options" class="A-1"></td>
                <td id="options" class="A-2"></td>
                <td id="options" class="A-3"></td>
                <td id="options" class="A-4"></td>
                <td id="options" class="A-5"></td>
                <td id="options" class="A-6"></td>
                <td id="options" class="A-7"></td>
                <td id="options" class="A-8"></td>
                <td id="options" class="A-9"></td>
                <td id="options" class="A-10"></td>
              </tr>
              <tr>
                <td width="1%">B</td>
                <td id="options" class="B-1"></td>
                <td id="options" class="B-2"></td>
                <td id="options" class="B-3"></td>
                <td id="options" class="B-4"></td>
                <td id="options" class="B-5"></td>
                <td id="options" class="B-6"></td>
                <td id="options" class="B-7"></td>
                <td id="options" class="B-8"></td>
                <td id="options" class="B-9"></td>
                <td id="options" class="B-10"></td>
              </tr>
              <tr>
                <td width="1%">C</td>
                <td id="options" class="C-1"></td>
                <td id="options" class="C-2"></td>
                <td id="options" class="C-3"></td>
                <td id="options" class="C-4"></td>
                <td id="options" class="C-5"></td>
                <td id="options" class="C-6"></td>
                <td id="options" class="C-7"></td>
                <td id="options" class="C-8"></td>
                <td id="options" class="C-9"></td>
                <td id="options" class="C-10"></td>
              </tr>
              <tr>
                <td width="1%">D</td>
                <td id="options" class="D-1"></td>
                <td id="options" class="D-2"></td>
                <td id="options" class="D-3"></td>
                <td id="options" class="D-4"></td>
                <td id="options" class="D-5"></td>
                <td id="options" class="D-6"></td>
                <td id="options" class="D-7"></td>
                <td id="options" class="D-8"></td>
                <td id="options" class="D-9"></td>
                <td id="options" class="D-10"></td>
              </tr>
              <tr>
                <td width="1%">E</td>
                <td id="options" class="E-1"></td>
                <td id="options" class="E-2"></td>
                <td id="options" class="E-3"></td>
                <td id="options" class="E-4"></td>
                <td id="options" class="E-5"></td>
                <td id="options" class="E-6"></td>
                <td id="options" class="E-7"></td>
                <td id="options" class="E-8"></td>
                <td id="options" class="E-9"></td>
                <td id="options" class="E-10"></td>
              </tr>
              <tr>
                <td width="1%">F</td>
                <td id="options" class="F-1"></td>
                <td id="options" class="F-2"></td>
                <td id="options" class="F-3"></td>
                <td id="options" class="F-4"></td>
                <td id="options" class="F-5"></td>
                <td id="options" class="F-6"></td>
                <td id="options" class="F-7"></td>
                <td id="options" class="F-8"></td>
                <td id="options" class="F-9"></td>
                <td id="options" class="F-10"></td>
              </tr>
              <tr>
                <td width="1%">G</td>
                <td id="options" class="G-1"></td>
                <td id="options" class="G-2"></td>
                <td id="options" class="G-3"></td>
                <td id="options" class="G-4"></td>
                <td id="options" class="G-5"></td>
                <td id="options" class="G-6"></td>
                <td id="options" class="G-7"></td>
                <td id="options" class="G-8"></td>
                <td id="options" class="G-9"></td>
                <td id="options" class="G-10"></td>
              </tr>
              <tr>
                <td width="1%">H</td>
                <td id="options" class="H-1"></td>
                <td id="options" class="H-2"></td>
                <td id="options" class="H-3"></td>
                <td id="options" class="H-4"></td>
                <td id="options" class="H-5"></td>
                <td id="options" class="H-6"></td>
                <td id="options" class="H-7"></td>
                <td id="options" class="H-8"></td>
                <td id="options" class="H-9"></td>
                <td id="options" class="H-10"></td>
              </tr>
              <tr>
                <td width="1%">I</td>
                <td id="options" class="I-1"></td>
                <td id="options" class="I-2"></td>
                <td id="options" class="I-3"></td>
                <td id="options" class="I-4"></td>
                <td id="options" class="I-5"></td>
                <td id="options" class="I-6"></td>
                <td id="options" class="I-7"></td>
                <td id="options" class="I-8"></td>
                <td id="options" class="I-9"></td>
                <td id="options" class="I-10"></td>
              </tr>
              <tr>
                <td width="1%">J</td>
                <td id="options" class="J-1"></td>
                <td id="options" class="J-2"></td>
                <td id="options" class="J-3"></td>
                <td id="options" class="J-4"></td>
                <td id="options" class="J-5"></td>
                <td id="options" class="J-6"></td>
                <td id="options" class="J-7"></td>
                <td id="options" class="J-8"></td>
                <td id="options" class="J-9"></td>
                <td id="options" class="J-10"></td>
              </tr>
            </tbody>
          </table>
        </div>
        <!-- <div id='oponentBoard' class='boards'> -->
      </div>
      <!-- <div class="col-md-6"> -->
    </div>
    <!-- <div class="col-md-8 col-md-offset-1 well well-md"> -->
  </div>
  <!-- <div class="row"> -->
</div>
Answer:1

public onChange(event: Event) { let files = event.target['files']; let list: string[]; console.log(files); for (var i = 0; i < files.length; i++) { if (FileReader && ...

public onChange(event: Event) { let files = event.target['files']; let list: string[]; console.log(files); for (var i = 0; i < files.length; i++) { if (FileReader && ...

  1. undefined array value javascript
  2. undefined array size java
  3. undefined array size
  4. undefined array size c
  5. undefined array c++
  6. undefined array typescript
  7. undefined array python
  8. undefined array angular
  9. undefined array java
  10. undefined array php
  11. undefined array js
  12. undefined array length javascript
  13. undefined array element javascript
  14. undefined array vba
  15. undefined array length java
  16. undefined array length c
  17. undefined array size vba
  18. undefined array element
  19. undefined array in perl
  20. undefined array angular2

Here is my code: $('body').not('.specific_element').css('opacity','.3'); body{ border: 1px solid; } .specific_element{ border: 1px solid red; } <script src="https://ajax.googleapis....

Here is my code: $('body').not('.specific_element').css('opacity','.3'); body{ border: 1px solid; } .specific_element{ border: 1px solid red; } <script src="https://ajax.googleapis....

  1. donald trump
  2. donovan mitchell
  3. donald trump twitter
  4. don toliver
  5. donuts
  6. donald trump age
  7. donatos
  8. donald glover
  9. donald trump net worth
  10. donuts near me
  11. donald trump jr
  12. donepezil
  13. don johnson
  14. donald trump speech today
  15. donna shalala
  16. donna summer
  17. donald cerrone
  18. don julio
  19. donnie darko
  20. don quixote

Trying to scrape the front page of a website (www.ozbargain.com) to return any content in the a tag that holds a reference to xbox but nothing is being returned to console. I believe the issue is with ...

Trying to scrape the front page of a website (www.ozbargain.com) to return any content in the a tag that holds a reference to xbox but nothing is being returned to console. I believe the issue is with ...

My code below doesn't allow the API user to update only one field by passing one request property. I can remove the null at userObj, but the UI developer will have to pass existing data from the ...

My code below doesn't allow the API user to update only one field by passing one request property. I can remove the null at userObj, but the UI developer will have to pass existing data from the ...

  1. update only some columns sql
  2. mongoose update only some fields
  3. mongodb update only some fields
  4. rails update only some attributes
  5. pandas update only some rows
  6. mysql update only some columns
  7. yum update only some packages
  8. nhibernate update only some fields
  9. mvc update only some fields
  10. sql update only some rows
  11. svn update only some files
  12. mysql update only some rows
  13. sql update only some fields
  14. mysql update only some fields
  15. entity framework update only some fields
  16. hibernate update only some fields
  17. jpa update only some fields
  18. entity framework update only some properties