Live comments preview for ExpressionEngine


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // Live Comment Preview jQuery function
  2. $(function() {
  3. $('#comment').one('focus',function() {
  4. });
  5. var $comment = '';
  6. $('#comment').keyup(function() {
  7. $comment = $(this).val();
  8. $comment = $comment.replace(/\n/g, "<br />").replace(/\n\n+/g, '<br ><br />').replace(/(<\/?)script/g,"$1noscript");
  9. $('p.live-preview').html($comment);
  10. });
  11. });
  12.  
  13.  
  14.  
  15. <div class="comment-preview">
  16. <h3>My Comment Preview</h3>
  17. <p class="live-preview">placeholder text</p>
  18. </div>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.