0

I have a textarea

<textarea id="postContent" class="input-block-level" placeholder="Tell us about it!" rows="4"></textarea>

and I need a script that highlights the links written inside the textarea, stores them in a variable (array) for later processing and removes all html-tags. The behavior is well-know from the tweet-box on twitter.

So the content could be

Look what I have found today on www.stackoverflow.com!

and in that case, www.stackoverflow.com should be highlighted (wrapped in a <p> f.e.) without the "!".

How would you do that with jQuery?

Raphael Jeger
  • 5,024
  • 13
  • 48
  • 79

1 Answers1

0

If you want to highlight link then you have to work with innerHTML of textarea....(I would not suggest that) your regex goes here = var regEx = /((ht|f)tps?://\S*)/g;

Secondly, you can identify links using click event inside textarea...click handler should look whether it is a url or plain text..if a link open new window..else return false....