Problem adding class to more lines of a form using jquery clone function
in Using jQuery
•
2 years ago
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?
- <script type='text/javascript'>
- $(document).ready(function(){
- $(".adicionarItens").click(function() {
- var linha_selecionada = $(this).parents( "tr");
- var novalinha = linha_selecionada.clone();
- novalinha.find("input").val("");
- novalinha.find("select").val("NAO");
- novalinha.find("span[id=boton]").parents( "td").remove();
- novalinha.find("span[id=boton2]").parents( "td").remove();
- //Insere conteudo dentro da tag body
- $("#funcionarios tbody:last ").append(novalinha);
- })
- };
- </script>
1