1
I am cloning a row in the table, I can insert a new value to the id, but I would like to concatenate a new value to the id existing.
$("#addRow").click(function() {
  $clone = $('#tabela tbody>tr:last')
    .clone(true)
    .insertAfter('#tabela tbody>tr:last');
  $clone.find('input').attr({
    'data-id': $('#tabela tbody>tr').length,
    'id': $('#tabela tbody>tr').length
  });
  $clone.find('input').val("");
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<table id="tabela">
  <tbody>
    <tr>
      <td><input type="text" name="nome-1" id="nome-1" /></td>
      <td><input type="text" name="funcao-1" id="funcao-1" /></td>
      <td><input type="text" name="setor-1" id="setor-1" /></td>
    </tr>
  </tbody>
</table>
<button id="addRow">AddRow</button>With each addition of a new line, the id must be:
nome-2
funcao-2
setor-2
...
nome-10
funcao-10
setor-10
It’s not enough to do:
'id': "test-" + $('#tabela tbody>tr').length?– Woss
This is just an example, @Andersoncarloswoss. There will be N inputs and that way it becomes unviable.
– Marcelo de Andrade