Problem adding class to more lines of a form using jquery clone function

Problem adding class to more lines of a form using jquery clone function

I have the following doubt, I am maintaining a form using the php language, it has a method that clones all content, that is, the body of a current row table for each time the user wants to create too many rows, well, this method is written in javascript using jquery. What happens, I added a select to this form and also a function for validating an input field to be required, but the cat's jump is in it, I add a new line, the function copies the current line and creates another one below, right, who does this is the .clone () method, from jquery, and when I edit the line below these changes fall on the line above, my validation function seems to only have an effect on the first line, I'm confused, as I leave and how to solve this bug, I would like a north. Thankful if anyone has a suggestion.

Well, I use another function to make the date field required

So, this function only occurs in the first line, in the cloned lines it does not provide effect, is there a plausible solution to this problem?


  1. <script type='text/javascript'>
  2.        $(document).ready(function(){
  3.        $(".adicionarItens").click(function() {
  4.               var linha_selecionada = $(this).parents( "tr");
  5.               var novalinha = linha_selecionada.clone();
  6.               novalinha.find("input").val("");
  7.               novalinha.find("select").val("NAO");
  8.               novalinha.find("span[id=boton]").parents( "td").remove();
  9.               novalinha.find("span[id=boton2]").parents( "td").remove();
  10.               //Insere conteudo dentro da tag body
  11.               $("#funcionarios tbody:last ").append(novalinha);
  12.          })
  13. };
  14. </script>