I am developing a simple rich text editor and I want to know if it could be possible to make a link inside a div. For it to be clear, let's have a sample scenario:
The user wanted to post on a blog, he then copies a link from the url and then paste it inside a ContentEditable div
and the program must make the copied text to a link
. Then when he clicks POST button, the program must get the html
code from the ContentEditable div
(for example: <a href="stackoverflow.com"> stackoverflow.com </a>
)
So far what I have is this HTML code here:
<div contentEditable=true id = "discussionmessage"></div>
<button id = "post"> POST </button>
and Javascript code here:
//alerts the text inside the ContentEditable div.
$("#post").click(function(){
alert(document.getElementById("discussionmessage").innerHTML);
});
Is it possible?