justhrun

jqueryregex

Jul 19th, 2017
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <title>Bla Bla Bla</title>
  5. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  6. <script>
  7. $(document).ready(function(){
  8. $('#pencet').on('click', function(){
  9. var arrText = $('#mytxtarea').val().trim().split('\n');
  10. var newText = '';
  11. $.each(arrText, function(i,text) {
  12. if(text.length < 1 || text == "\r\n" || text == "\n" || text == "\r" || text == "\n\r") {
  13. return true;
  14. }
  15. newText+= text.trim()+'\n';
  16. });
  17. alert(newText);
  18. });
  19. });
  20. </script>
  21. </head>
  22. <body>
  23. <center>
  24. <textarea name="mytxtarea" id="mytxtarea" rows=7 cols=33>This is a sample text</textarea>
  25. <br>
  26. <button id=pencet>test</button>
  27. <center>
  28. </body>
  29. </html>
Advertisement
Add Comment
Please, Sign In to add comment