0

I have created a post in Django. When a user types text and hits submit it shows in the page. Now I want to turn any hashtags in the text in to links. For example if a user types #sometext it will show a link in the HTML replacing #sometext. I was working on this and i got an error:

Uncaught SyntaxError: Unexpected token ','

$(document).ready(function() {
  $('.reply-btn').click(function() {
    $(this).parent().parent().next('.replied-comments').fadeToggle()
  });
});

$(document).ready(function() {
  function updateHashLinks() {
    $("p").each(function(data) {
      var hashtagRegex = /(^|\s)#([\w\d-]+)/g
      var newText = $(this).html().replace(hashtagRegex, "$1<a href='/tags/$2/'>#$2</a>")
      $(this).html(newText)
    });
  },
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Jack Ryan
  • 17
  • 10

0 Answers0