Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Text Editor</title>
- </head>
- <body>
- <style type="text/css">
- .hastags{
- color:blue;
- font-style: bold;
- }
- </style>
- <textarea id="editor" onkeyup="checkworld();"></textarea>
- <div id="muncul"></div>
- <script type="text/javascript">
- function checkworld(){
- var content = document.getElementById('editor').value;
- var newContent = content.replace(/(^|\s)#(\w+)/gi, '<a class="hastags" href="#$2">#$2</a>');
- document.getElementById('muncul').innerHTML = newContent;
- document.getElementById('editor');
- console.log(content);
- console.log(newContent);
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment