0

I need some help from JavaScript developers

I have a chat box where I send their own message with the input, and they may send a link along with the message, and I want to put the links that are sent next to the messages in a tag so that they can be clicked.

for example

 <div class="messages"> hello my friend this is your link  https://strackoverflow.com  see you later </div>

Now I want to select all the divs that have the messages class And check its string if it contains http and there is a space at the end of http Put that part of the link inside the a tag with target _blank

3
  • have you tried anything on your end first? Commented Sep 14, 2022 at 5:50
  • Please add a minimal reproducible example stackoverflow.com/help/minimal-reproducible-example Commented Sep 14, 2022 at 5:53
  • Hello, there! welcome to SO :) as others have pointed out, having a code snippet in your question will help us help you better. To help you get on the right track, you probably want to use a regex to find the URLs in your content. This SO question should help you get started Commented Sep 14, 2022 at 6:45

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.