tegarkurniawan

Texteditor

Jun 28th, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Text Editor</title>
  5. </head>
  6. <body>
  7. <style type="text/css">
  8. .hastags{
  9. color:blue;
  10. font-style: bold;
  11. }
  12. </style>
  13. <textarea id="editor" onkeyup="checkworld();"></textarea>
  14. <div id="muncul"></div>
  15. <script type="text/javascript">
  16.  
  17. function checkworld(){
  18. var content = document.getElementById('editor').value;
  19. var newContent = content.replace(/(^|\s)#(\w+)/gi, '<a class="hastags" href="#$2">#$2</a>');
  20. document.getElementById('muncul').innerHTML = newContent;
  21. document.getElementById('editor');
  22. console.log(content);
  23. console.log(newContent);
  24. }
  25. </script>
  26. </body>
  27.  
  28. </html>
Advertisement
Add Comment
Please, Sign In to add comment