/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$(function() { $('#comment').one('focus',function() { }); var $comment = ''; $('#comment').keyup(function() { $comment = $(this).val(); $comment = $comment.replace(/\n/g, "<br />").replace(/\n\n+/g, '<br ><br />').replace(/(<\/?)script/g,"$1noscript"); $('p.live-preview').html($comment); }); }); <div class="comment-preview"> <h3>My Comment Preview</h3> <p class="live-preview">placeholder text</p> </div>