I am facing difficulty in small task because I am new to jQuery. I have a table where each table row has a icon, on click of that icon, a modal box opens containing some words. When I close this modal box, I want to gather table row which against that modal box appear.

For example:

```
table
  row1 +
  row2 +
  row3 +

```

On click of row2 + button, it open modal box, on closing of that modal box , I want that row against that modal box opened that will be 2 in that case.

I have written the code shown below. 

Modal Box:

```
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Choose words. You can add words, delete words </h4>
      </div>
      <div class="modal-body">
      <!-- <input type="text" value="Amsterdam,Washington,Sydney,Beijing,Cairo" data-role="tagsinput" /> -->
      <div class="modal-body-inner"></div>
      </div>
      <div class="modal-footer">
        <button type="button" id = "modelformbuttonclick" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>

```

Table rows:

```
<table>
<tr id="1">
  <td><td>
  <td><span id="modelbox" data-target="#myModal" href="#myModal" data-toggle="modal" class="glyphicon glyphicon-plus"></span></td> 
</td>
<tr id="2">
  <td><td>
  <td><span id="modelbox" data-target="#myModal" href="#myModal" data-toggle="modal" class="glyphicon glyphicon-plus"></span></td> 
</td>                   
<tr id="3">
  <td><td>
  <td><span id="modelbox" data-target="#myModal" href="#myModal" data-toggle="modal" class="glyphicon glyphicon-plus"></span></td> 
</td>  
</table>   

```

On click of modal box it get populated by dynamic value using jQuery.

```
$('tr #modelbox').click(function() {
   var $row = $(this).closest('tr');
   var tbid = $row.attr('id'); // table row ID
   var fieldOption = []
   $row.find('#words option').each(function() { fieldOption.push($(this).val()); });
   console.log(fieldOption);

    $('.modal-body-inner').html('');
    for(var i = 0, size = fieldOption.length; i < size ; i++){
          var item = fieldOption[i];
          $('.modal-body-inner').append("<span class=" + "span1" + " id = "+ tbid +"> "+ item + "</span>");
    }
});

```

And On click of Close button I want to get row, I am getting row like this but it is not working, 

```
$('#modelformbuttonclick').click(function() {
    console.log($(this).closest('tr').data('id'));
    console.log($(event.target).closest('tr').data('id'));
});

```

So Hope you understand my question any help regarding this will be appreciated.