自动检测文本区域字段中的链接
如何突出显示文本区域中的超链接。 我创建了一个如下所示的标签,
<textarea
class="textarea"
name="input_note"
id=""
cols="30"
rows="10"
></textarea>
假设这个输入字段用于记笔记并保存在那里(更像是谷歌保留)。因此,当用户在输入字段中输入任何“链接”时,链接将显示为纯文本而不是超链接。该链接也不像通常那样突出显示。
---输入字段我已保存了带有链接的注释 - 'https://stackoverflow.com/' 但是当显示注释时,
> https://stackoverflow.com/
会显示纯文本并且不可单击。
How can I highlight hyperlinks in textarea.
I have created a tag as shown below
<textarea
class="textarea"
name="input_note"
id=""
cols="30"
rows="10"
></textarea>
let's say this input field is used to take a note and saves there(more like a google keep). so when the user inputs any 'links' in the input field, the links are shown as plain text instead of hyperlink. The link is also not highlight as normally has.
---input field I have saved a note with the link- 'https://stackoverflow.com/'
but when the note is displayed
> https://stackoverflow.com/
plain text is displayed and not clickable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这段代码应该可以工作。我必须用 div 替换 textarea,因为它不可能在 textarea 中执行您想要的操作,但我给了它样式,使其看起来就像 textarea 一样。
Stackoverflow has blocked <a tags so you wont be able to go to a website if u try to run the snippet. Copy the code in the file and it would work.
This code should work. I had to replace the textarea with div because its impossible to do what you want in textarea but I gave it styling so that it looks just like a textarea.
Stackoverflow has blocked <a tags so you wont be able to go to a website if u try to run the snippet. Copy the code in the file and it would work.