Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
- <html lang="pt-br">
- <head>
- <meta charset="utf-8">
- <title>...</title>
- <style>
- body { margin:0; }
- </style>
- </head>
- <body>
- <input type="text" class="form-control" name="inicial" id="inicial" value="@hotmail.com" placeholder="@hotmail.com">
- <br />
- <br />
- <tr align="center" bgcolor="#000000">
- <td height="10" colspan="2"><span class="texto">Lista de emails</span>
- </tr>
- <tr align="right">
- <td height="136" colspan="2" valign="top">
- <br>
- <textarea name="emails" style="width:100%" rows="8" wrap="VIRTUAL" class="form" id="emails">
- teste@aol.com
- teste2@gmail.com
- xxxxx@hotmail.com
- yyyyy@provedor.com
- meuemail
- </textarea>
- <span class="alerta">Click > </span>
- </td>
- </tr>
- <tr>
- <td height="26" align="right" valign="top" colspan="2">
- <input type="submit" name="Submit" id="enviar" value="Substituir">
- </td>
- </tr>
- </body>
- <script type="text/javascript">
- $('#enviar').on('click', function() {
- // Array dos resultados:
- var value = [];
- // String do sufixo (a ser inserido):
- var sufixo = $('#inicial').val();
- // Executa função em cada linha:
- $.each($('textarea').val().split('\n'), function(index, data){
- // Se tiver algo escrito remove o sufixo (se já existir!) e adiciona o sufixo:
- if(data.trim() !== ""){
- value.push(data.trim().split('@')[0] + sufixo);
- }
- });
- // Junta a array inserindo quebra de linhas entre eles
- $('textarea').val(value.join("\n"));
- });
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement