Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.44 KB | None | 0 0
  1. var corpoTabela = $(".table").find("tbody");
  2.  
  3. $(document).ready(function(){
  4.     if(criarLinha()){
  5.         $('.cpf').mask('000.000.000-00', { reverse: true });
  6.     }    
  7. });
  8.  
  9. $("#botao-incluir").click(function(event){
  10.     event.preventDefault();
  11.  
  12.     var novaLinha = criarLinha();
  13.  
  14.     corpoTabela.append(novaLinha);  
  15. });
  16.  
  17. $("#botao-salvar").click(function(event){
  18.     event.preventDefault();
  19.     salvaDados();
  20. });
  21.  
  22. $("#botao-limpar").click(function(event){
  23.     event.preventDefault();
  24.     $(".nome").val(" ");
  25.     $(".idade").val(" ");
  26.     $(".cpf").val(" ");
  27. });
  28.  
  29. corpoTabela.on("dblclick", function(){
  30.     if(confirm("Deseja mesmo remover essa linha ?")){
  31.         var alvoEvento = event.target;
  32.         var paiDoAlvo = alvoEvento.parentNode;
  33.         paiDoAlvo.remove();
  34.     }
  35. });
  36.  
  37. function criarLinha(){
  38.     var linha = $("<tr class='funcionarios'>");
  39.     var inputNome = $("<input type='text' class='nome'>");
  40.     var inputIdade= $("<input type='text' class='idade'>");
  41.  
  42.     var inputSexo = $("<input type='text' class='cpf'>");
  43.  
  44.     var colunaNome = $("<td>").append(inputNome);
  45.     var colunaIdade = $("<td>").append(inputIdade);
  46.     var colunaSexo = $("<td>").append(inputSexo);
  47.  
  48.     linha.append(colunaNome);
  49.     linha.append(colunaIdade);
  50.     linha.append(colunaSexo);
  51.  
  52.     return linha;
  53. }
  54.  
  55. function salvaDados()
  56. {
  57.     var funcionarios = $('.funcionarios');
  58.    
  59.  
  60.     console.log(funcionarios);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement